Syntax Error

santhosh23

Registered User.
Local time
Today, 16:13
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.

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

thank you
 
Hi..I tried that link but still I am getting the syntax error ..this is my 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

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)

and Is this correct ..Private Sub txtbarcode_BeforeUpdate(Cancel As Integer) I dunno how it comes as cancel as integer in code builder becoz i am trying to get the barcode value which is a integer
can you give me some inputs..
 
What data type is toolCareJob? Can you post the db here with the failing code?

Yes, the Cancel As Integer is correct. The before update event can be cancelled, and setting Cancel = True is how you do it. The before update event of a control or the form is typically where validation is done, since they can be cancelled.
 
Apparently this worked?

Barcodefromtable = DLookup("Barcode", "Barcode_Table", "toolCareJob= '" & Me.cbotoolCare_Job & "'")

In the future, please don't post the same question twice.
 
HI ..Sorry for posting that twice..Yeah it worked..I gave both as string..thank you
 

Users who are viewing this thread

Back
Top Bottom