Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check 3 lines on subform before exiting main form?

Status
Not open for further replies.

fsweb2002

Programmer
Apr 11, 2002
94
TR
Hi

I have a Puchase Order form with a subform. I can enter as many lines as I want on the subform.

What I need to do is the following:
When exiting the PO form, I need a routine to check the 3 lines (or whatever many lines that have been entered...) to see if a certain field matches a certain criteria.

For example, on PO #1000, with lines 1,2,3
check field [linetype] to see if it is "LCL" or "FCL".
If all lines are "LCL" then display message#1 otherwise display message#2

I know how to query the lines (via SQL) however I am looking for a faster/easier way which doesn´t require to run an SQL, but to use the info which is already on the screen.

Your input is appreciated.

 
In the before update event on your main form put code similar to the following. I am at work so this may not be exactly syntactically correct. Assume that your subform control on the main form is named Subform1 and the controls on the subform are named Ctl1 and Ctl2.

If form("Subform1").form("Ctl1") = "LCL" And _
form("Subform1").form("Ctl2") = "LCL" Then
error message
Cancel = True
else
non error code
end if

By using Cancel = True you stop the user from being able to exit the form without taking care of the errors.

Have a great day!

 
Thanks for your reply SBendBuckeye,

I don´t think that´s what I wanted...
The subform has several lines (continuous form) which means the control is always the same name, so I can´t do a reference to the same control for 3 different lines...

Any other way?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top