I've tried everything I can think of and can't figure this out.
This works when RUN from SQL view:
It returns the correct record.
This returns a syntax error:
I can't figure the proper syntax to embed # on each side of my date function.
Barcode is DateTime on the table, Default Value=NOW().
This is the test code I'm using:
I'm adding a ZIPped copy of this test code. It has just the gutted database, form and queries.
Robert
EDIT: dtBarcode has been changed to Public in code above and new ZIP.
EDIT SOME MORE: Adding search strings to help me in 5 years when I'll have the same darned problem:
SQL embed date function where clause statement # pound sign
This works when RUN from SQL view:
Code:
SELECT PartID
FROM Inventory
WHERE [Barcode]=#[U]2014-02-13 02:20:42[/U]#;
This returns a syntax error:
Code:
SELECT PartID
FROM Inventory
WHERE [Barcode]=#[U]ReturnBarcode()[/U]#;
I can't figure the proper syntax to embed # on each side of my date function.
Barcode is DateTime on the table, Default Value=NOW().
This is the test code I'm using:
Code:
Public dtBarcode As Date
Public Function ReturnBarcode() As Date
ReturnBarcode = dtBarcode
End Function
Private Sub Form_Current()
Part.BackColor = LabelColour
End Sub
Private Sub Form_Load()
Dim lngPartID As Long
dtBarcode = DateValue("2014-02-13") + TimeValue("02:20:42")
lngPartID = DLookup("[PartID]", qryInventoryGetPartID)
End Sub
I'm adding a ZIPped copy of this test code. It has just the gutted database, form and queries.
Robert
EDIT: dtBarcode has been changed to Public in code above and new ZIP.
EDIT SOME MORE: Adding search strings to help me in 5 years when I'll have the same darned problem:
SQL embed date function where clause statement # pound sign
Attachments
Last edited: