Access 2007, not compiled, not split, Windows 64 bit Pro. Skill level moderate. One user stand alone, not networked.
Having a problem with syntax on an update query. Debug.Print returns all the correct information. The watches on the variables all come up correct. I'm not sure what's wrong.
Only one record exists in the table to be updated. There will never be more than one record. This is an override fix for a client. The only error I get is 3144 Syntax error.
Private Sub CmbPickSiteCount_AfterUpdate()
Dim stSQL As String
Dim intSiteCatID As Integer
Dim stSiteName As String
Dim intCount As Integer
Dim intSiteID As Integer
Dim intCustID As Integer
Dim stCustName As String
Dim stCatNM As String
intSiteCatID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(0)
stSiteName = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(1)
intCount = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(2)
intSiteID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(3)
intCustID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(4)
stCustName = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(5)
stCatNM = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(6)
stSQL = "UPDATE Tbl_ScheduledMeal6_Override" _
& " SET SiteName = '" & stSiteName & "'," _
& " SET DefaultCount = " & intCount & "," _
& " SET SiteID = " & intSiteID & "," _
& " SET CustID = " & intCustID & "," _
& " SET CustName = '" & stCustName & "'," _
& " WHERE CategoryName = '" & stCatNM & "';"
Debug.Print stSQL
DoCmd.RunSQL stSQL
End Sub
Results printed by Debug.Print:
UPDATE Tbl_ScheduledMeal6_Override SET SiteName = 'Kids Station', SET DefaultCount = 30, SET SiteID = 186, SET CustID = 113, SETUPDATE Tbl_ScheduledMeal6_Override SET SiteName = 'Kids Station', DefaultCount = 30, SiteID = 186, CustID = 113, CustName = 'Kids Station', WHERE CategoryName = 'LUNCH - PRESCHOOL';
CustName = 'Kids Station', WHERE CategoryName = 'LUNCH - PRESCHOOL'
Appreciate any help.
Having a problem with syntax on an update query. Debug.Print returns all the correct information. The watches on the variables all come up correct. I'm not sure what's wrong.
Only one record exists in the table to be updated. There will never be more than one record. This is an override fix for a client. The only error I get is 3144 Syntax error.
Private Sub CmbPickSiteCount_AfterUpdate()
Dim stSQL As String
Dim intSiteCatID As Integer
Dim stSiteName As String
Dim intCount As Integer
Dim intSiteID As Integer
Dim intCustID As Integer
Dim stCustName As String
Dim stCatNM As String
intSiteCatID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(0)
stSiteName = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(1)
intCount = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(2)
intSiteID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(3)
intCustID = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(4)
stCustName = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(5)
stCatNM = Forms!frm_main!Frm_AddDateToCategoryParent!CmbPickSiteCount.Column(6)
stSQL = "UPDATE Tbl_ScheduledMeal6_Override" _
& " SET SiteName = '" & stSiteName & "'," _
& " SET DefaultCount = " & intCount & "," _
& " SET SiteID = " & intSiteID & "," _
& " SET CustID = " & intCustID & "," _
& " SET CustName = '" & stCustName & "'," _
& " WHERE CategoryName = '" & stCatNM & "';"
Debug.Print stSQL
DoCmd.RunSQL stSQL
End Sub
Results printed by Debug.Print:
UPDATE Tbl_ScheduledMeal6_Override SET SiteName = 'Kids Station', SET DefaultCount = 30, SET SiteID = 186, SET CustID = 113, SETUPDATE Tbl_ScheduledMeal6_Override SET SiteName = 'Kids Station', DefaultCount = 30, SiteID = 186, CustID = 113, CustName = 'Kids Station', WHERE CategoryName = 'LUNCH - PRESCHOOL';
CustName = 'Kids Station', WHERE CategoryName = 'LUNCH - PRESCHOOL'
Appreciate any help.