dlookup data type mismatch

cjamps

Registered User.
Local time
Today, 18:37
Joined
Feb 2, 2009
Messages
29
I have 2 tables. One is called DOCKETS and one is called TASK LIST. The field serialnumber in
DOCKETS is the primary key which is related to the field serialnumber in table TASK LIST. The table DOCKETS
has a field called DocketNumber. Both fields, serialnumber and docketnumber are unique and can not
have duplicates. From a form I would like the user to type in the serialnumber
(which is a text field) and the docketnumber related to that serialnumber should show up and not be allowed
to be edited. Hence I have the following. However I keep getting data type mismatch.

Private Sub SerialNumber_AfterUpdate()
DocketNumber = DLookup("DocketNumber", "Dockets", "SerialNumber= " & SerialNumber)
End Sub

Can anyone help?
 
your syntax should work if serial number is a number, but if it is a text type then it needs to be in a single quote, try the following:

DocketNumber = DLookup("DocketNumber", "Dockets", "SerialNumber= '" & SerialNumber & "'")
 
I have done as you asked and I get the error "You can't assign a value to this object". As soon as I start typing the serialnumber the next field which is docketnumber shows up as #name.
 
Just to confirm:
your form in unbound and not linked to any table
you have 2 text boxes Serialnumber and DocketNumber on the form both unbound ie control source is blank

dont use an afterupdate, just put the following:
DLookup("DocketNumber", "Dockets", "SerialNumber= '" & SerialNumber & "'")
in the control source of the docketnumber textbox
 
just check the following:
the form is unbound
both text boxes serialnumber and docketnumber are unbound

dont use the afterupdate event, just put the following in the control source of text box docketnumber
DLookup("DocketNumber", "Dockets", "SerialNumber= '" & SerialNumber & "'")
 
you may have to put serialnumber in square brackets:

DLookup("DocketNumber", "Dockets", "SerialNumber= '" & [SerialNumber] & "'")
 

Users who are viewing this thread

Back
Top Bottom