From a form check if a name exists on a different table

  • Thread starter Thread starter S. Matthew
  • Start date Start date
S

S. Matthew

When I select a name from a combo box in a form I would
like it to search another table to check if the selected
name exists. If the name exists in the table a flag
image should appear on the form.

Please help me write the code for this operation.

Thanks
S. Matthew
 
Probably the easiest way is to use the DLookup function
If DLookup("nameField","table to check","nameField = '" & me.your combo box
control name & "'") Then
turn on your flag
End if

The above assumes your name field is a text field - so you use the single
quote inside the double quotes.
HTH

TK
 
Use DLookup() to see if the entry exists.
For an explanation of how to use it, see:
Getting a value from a table: DLookup()
at:
http://members.iinet.net.au/~allenbrowne/casu-07.html

You could set the ControlSource of your text box to:
=IsNull(DLookup(...))
and set the Format property to the flag character (using the Wingdings
font).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top