Syntax Error

santhosh23

Registered User.
Local time
Today, 14:33
Joined
Jul 21, 2015
Messages
74
Hi

I am trying to get my Barcode value from my table, by comparing other field called toolcarejob which is also present in the table and will be given in navigation form, but while executing my code I got syntax error. Any help on below syntax will be appreciated.

Private Sub txtbarcode_BeforeUpdate(Cancel As Integer)

Barcodefromtable = DLookup("Barcode", "Barcode_Table", "toolCareJob = '" & forms! Navigation Form!toolCareJob & "'")


Barcodefromscanner = Me.txtbarcode.Value

If Barcodefromtable = Barcodefromscanner Then

DoCmd.Save

Else

MsgBox "Barcode and ToolCareJob Not Matching"

End If
End Sub

I tried these options too.

Barcodefromtable = DLookup("[Barcode]", "[Barcode_Table]", "[toolCareJob]= " & Forms! Navigation form! toolCareJob)


Barcodefromtable = DLookup("Barcode", "Barcode_Table", "toolCareJob = " & forms! Navigation form!toolCareJob)
 
if you have a space in the name (dont use spaces)
you must use brackets

forms! [Navigation Form]!toolCareJob

(if this is the correct name: NAVIGATION FORM
 
Hi Thanks for the reply..I tried the brackets ..I got the Runtime error 6 overflow..can you give some inputs..i tried this code.

Private Sub txtbarcode_BeforeUpdate(Cancel As Integer)

Barcodefromtable = DLookup("Barcode", "Barcode_Table", "toolCareJob = '" & Forms![Navigation Form]!toolCareJob & "'")

Barcodefromscanner = Me.txtbarcode.Value

If Barcodefromtable = Barcodefromscanner Then

DoCmd.Save
 
overflow is something else, the code worked, but
Barcodefromtable cant hold the info.

is Barcodefromtable defined as something? Dim Barcodefromtable as ???
 
Hi ..I just googled and tried this one ..
Barcodefromtable = DLookup("Barcode", "Barcode_Table", "toolCareJob= '" & Me.cbotoolCare_Job & "'")

it worked..yeah Barcodefromtable as string is defined..

Thank you so much
 

Users who are viewing this thread

Back
Top Bottom