J
jrtmax
In the VB code for a Command Button I want to execute two SQL commands on the
database. The first one is an insert and runs just fine. However, the
second one is an update and is not working. Do I need to declare another
variable for the second SQL command? See below:
Dim loDB As DAO.Database
Set loDB = CurrentDb
Dim lsSQL As String
lsSQL = "INSERT INTO 5_Def_Item ([ITEM_ID],[Eval_Frmwk_Chart]) " & _
"VALUES('" & Me![InvisibleID1] & "',2)"
Dim loQD As DAO.QueryDef
Set loQD = loDB.CreateQueryDef("", lsSQL)
Call loQD.Execute
lsSQL = "UPDATE [1_All Data] " & _
"INNER JOIN 5_Def_Item ON [1_All Data].ID = [5_Def_Item].Item_ID " & _
"SET [1_All Data].[Def Item ID] = [5_Def_Item].Def_Item_ID, " & _
"[1_All Data].[Def Item?] = True " & _
"WHERE [5_Def_Item].Item_ID = ('" & Me![InvisibleID1] & "')"
Call loQD.Execute
Is the lsSQL variable not getting updated with the second SQL command?
Thanks!
database. The first one is an insert and runs just fine. However, the
second one is an update and is not working. Do I need to declare another
variable for the second SQL command? See below:
Dim loDB As DAO.Database
Set loDB = CurrentDb
Dim lsSQL As String
lsSQL = "INSERT INTO 5_Def_Item ([ITEM_ID],[Eval_Frmwk_Chart]) " & _
"VALUES('" & Me![InvisibleID1] & "',2)"
Dim loQD As DAO.QueryDef
Set loQD = loDB.CreateQueryDef("", lsSQL)
Call loQD.Execute
lsSQL = "UPDATE [1_All Data] " & _
"INNER JOIN 5_Def_Item ON [1_All Data].ID = [5_Def_Item].Item_ID " & _
"SET [1_All Data].[Def Item ID] = [5_Def_Item].Def_Item_ID, " & _
"[1_All Data].[Def Item?] = True " & _
"WHERE [5_Def_Item].Item_ID = ('" & Me![InvisibleID1] & "')"
Call loQD.Execute
Is the lsSQL variable not getting updated with the second SQL command?
Thanks!