Query within a form

stauartadair

Registered User.
Local time
Today, 06:56
Joined
Sep 28, 2007
Messages
12
Hello all,

I've got a form which has a field called courier_number.

When data is entered in the field I want to query a yes/no field called active. If its no then display an alert message.
If its yes then do nothing.


Help !!!
 
If the yes/no field is in a separate table, modify the table's RecordSource query to join to it so you have the value available when you need it. Then in the BeforeUpdate event of the courier_number field, add the code to display the message. It will look something like:

If Me.Active = true then
Else
MsgBox "The Courier is not active. Please choose a new one.",vbOKOnly
Cancel = True
me.Courier_Number.Undo
Exit Sub
End if
 
Thanks Pat. I've actually got the record field called active in the same table as all the other fields. Its called main_table.

For this to work do I need to create a new table and create a relationship with the courier number and active field ?

Stu
 
No. I suggested the query because it sounded like the field you needed to check was in some other table. The code I suggested works as long as the field is in the form's RecordSource.
 

Users who are viewing this thread

Back
Top Bottom