Question DLookup I think

LogicDoc

New member
Local time
Today, 04:41
Joined
Sep 26, 2012
Messages
5
I have a form to input data to a table. what I am trying to do is: if i enter a duplicate serial number then i want to check another field to make sure the serial number was entered as a different order type.

i.e dropdown list fields are ....new order,repair order,replacement order, etc...
if the serial number i enter exists on the table I need to compare the order type to make sure they are different.??????
below is all i have for the serial number. How would i compare the other field once i run the code below?:banghead:

If DLookup("[Meter Serial Number]", "[table1]", "[meter serial number] = '" & [Forms]![Data Entry]![meter serial number] & "'") > 0 Then
MsgBox "DUPLICATE SERIAL NUMBER" & Chr(13) & " please enter unique serial number or change the order type!", vbExclamation, "DUPLICATE SERIAL NUMBER"
Meter_Serial_Number.SetFocus
MsgNumber = 9
Exit Sub
End If
 
How is the serial number being assigned?

You could do
If DCount("[meter serial number]" & "secondfieldname","table1") >0 Then
Msgbox " this serial number and secondfieldname already exist"....



Post entry comment: Geez I see John answered while I was typing.
 
Last edited:
deeply in debted for all the help....



DCount("[meter serial number]" & "[Order type]","table1")

this is taking place on click to save to table. what the rest of the code look like to compare these to table fields to the two form fields and decide if its duplicate or not....sorry i am really new at this.
 

Users who are viewing this thread

Back
Top Bottom