Have following code and can't get it to recognize integer variable (in blue). It presents perfectly in the immediate window. The query is all on one line in the ap. BayCounts.[ID] and intBay are both long integers. The query runs if I replace the variable with a literal number, like 6.
Private Sub Fill50btn_Click()
Dim updateBaySQL As Variant 'For update Query
Dim BayNm As Variant 'Value Passed from BayForm
BayNm = Me.Controls("ShowBay").Value
Dim intBay As Integer
intBay = CLng(Right(BayNm, 2))
updateBaySQL = "UPDATE BayCounts SET BayCounts.StCount = 600, BayCounts.[Count] = 600, BayCounts.AddDate = Date(), BayCounts.AddTime = Time() WHERE BayCounts.ID = intBay"
DoCmd.SetWarnings False
DoCmd.RunSQL updateBaySQL
DoCmd.SetWarnings True
End Sub
Thanks
jpl
Private Sub Fill50btn_Click()
Dim updateBaySQL As Variant 'For update Query
Dim BayNm As Variant 'Value Passed from BayForm
BayNm = Me.Controls("ShowBay").Value
Dim intBay As Integer
intBay = CLng(Right(BayNm, 2))
updateBaySQL = "UPDATE BayCounts SET BayCounts.StCount = 600, BayCounts.[Count] = 600, BayCounts.AddDate = Date(), BayCounts.AddTime = Time() WHERE BayCounts.ID = intBay"
DoCmd.SetWarnings False
DoCmd.RunSQL updateBaySQL
DoCmd.SetWarnings True
End Sub
Thanks
jpl