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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Dlookup to validated information

Status
Not open for further replies.

NakedZero

Technical User
Oct 27, 2004
21
US
I am trying to use the Dlookup function to validate whether or not the information typed in a text box is in a table. For example, I want to know if a specific State is in a Table. I have looked at the FAQ, but I can not seem to get this to work. Basically what I want to do for test purposes is this:

If Me.strMA_State = DLookup("[strma_state]", "tblstate_ooa_non_Contiguous") Then
MsgBox "success"
End If

this is how it reads (In my head): if State is in Table then
success.

I will go on to execute code I will write, but can not get past this trivial part as of yet :( Any help with the Dlookup function is much appreciated!
 
If Me.strMA_State = DLookup("strma_state", "tblstate_ooa_non_Contiguous", "strma_state='" & Me.strMA_State & "'") Then
MsgBox "success"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the fast reply, I tried that and it returns successfull even when the state is not in that table, any Ideas?
 
NM It was an ID10T error, I wasn't using the other table's field name, it works, I thought I was doing something wrong with the syntax. I had what you posted to begin with, but didn't have the correct field name, DOH!

Thanks for your help and quick reply!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top