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

search table before opening form

Status
Not open for further replies.

Fonzie

MIS
Feb 16, 2001
74
0
0
CA
I have a form with a button that opens a second form. What I need it to do is to search a table to see if a field contains a specific value (equal to field on current form). If the field contains the required value, continue opening second form. If not, just display a message box that says 'Value not entered'. How do you go about this?
 
Have a look at the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. I tried entering the following be keep getting an 'Expected:=' error. Whats going on?

DLookup("[assettag]", "[test1]", "[assettag]='"& forms!frmInventory!txtAssetTag &"'")
 
I tried entering the following
Where ?

A starting point:
If IsNull(DLookup("assettag", "test1", "assettag='" & Me!txtAssetTag & "'") Then
MsgBox Me!txtAssetTag & " : Value not entered"
Exit Sub
End If
DoCmd.OpenForm ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OOps, sorry for the typo:
If IsNull(DLookup("assettag", "test1", "assettag='" & Me!txtAssetTag & "'")) Then
MsgBox Me!txtAssetTag & " : Value not entered"
Exit Sub
End If
DoCmd.OpenForm ...
 
How are ya Fonzie . . .

[blue]PHV[/blue] has you in tow, only I'm thinking more like:
Code:
[blue]   Dim Criteria As String
   
   Criteria = "assettag='" & Me!txtAssetTag & "'"
   
   If IsNull(DLookup("[assettag]", "test1", Crireria)) Then
      MsgBox Me!txtAssetTag & " : Value not entered"
   Else
      DoCmd.OpenForm ...
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top