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

dlookup syntax question

Status
Not open for further replies.

stuckagain1

Technical User
May 3, 2004
86
0
0
US
can you have more than one criteria in the dlookup expression? i can never get it to work if i need two pieces of criteria....

dlookup([id],"table","field1=me.field1 and field2=me.field2")

me.field1 and me.field2 are on my form (and in the table) and i'm trying check after field1 is updated if field1 and field2 's data matches the data in the table, ie it would be a duplicate entry......

thanks-
 
Try this in Field1_AfterUpdate():

Dim Lkup As Variant
Dim MsgBoxValue As Integer

Lkup = DLookup("[id]","table","field1="Forms!MyForm!field1 and "field2="Forms!MyForm!field2")

If Not IsNull(Lkup) Then
MsgBoxValue=MsgBox("This is a duplicate record",vbOKOnly,"Duplicate Record:")
EndIf
End Sub

MrBill
 
DLookUp("id", "table", "field1='" & Me!control1 & "' and field2='" & Me!control2 & "'")


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks--

this is what i have and i get a data type mismatch in criteria error.......argghh

If IsNull(DLookup("id", "outreach", "outreach_date='" & Me!OUTREACH_DATE & "' and ID='" & Me!ID & "'")) Then

is it the date field??
 
If outreach_date is defined as DateTime in outreach:
If IsNull(DLookup("id", "outreach", "outreach_date=#" & Me!OUTREACH_DATE & "# and ID='" & Me!ID & "'")) Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top