B
BobV
Group:
I am trying to execute an Update Query using a variable for the Company
Name. The first sub below updates the CompanyOpen field of the MasterData
table correctly. (Note that it does not use a variable for the Company
Name.)
However, the second sub does not update the MasterData table. In the second
sub I am using a variable for the Company Name.
Can someone give me some insight as to why the second sub is not updating
the CompanyOpen field in the MasterData table? Any help will be greatly
appreciated.
Thanks,
BobV
Sub UpdateMasterData1() <-----This sub updates the table correctly
Dim db As Dao.Database
Dim CompanyName As String
Set db = CurrentDb
db.Execute "UPDATE MasterData SET MasterData.CompanyOpen = 1 WHERE
(((MasterData.Name)=""Sample Company 12-31-06""));"
End Sub
Sub UpdateMasterData2() <-----This sub does NOT update the table
correctly
Dim db As Dao.Database
Dim CompanyName As String
CompanyName = "Sample Company 12-31-06"
Set db = CurrentDb
db.Execute "UPDATE MasterData SET MasterData.CompanyOpen = 1 WHERE
(((MasterData.Name)="" & CompanyName & ""));"
End Sub
I am trying to execute an Update Query using a variable for the Company
Name. The first sub below updates the CompanyOpen field of the MasterData
table correctly. (Note that it does not use a variable for the Company
Name.)
However, the second sub does not update the MasterData table. In the second
sub I am using a variable for the Company Name.
Can someone give me some insight as to why the second sub is not updating
the CompanyOpen field in the MasterData table? Any help will be greatly
appreciated.
Thanks,
BobV
Sub UpdateMasterData1() <-----This sub updates the table correctly
Dim db As Dao.Database
Dim CompanyName As String
Set db = CurrentDb
db.Execute "UPDATE MasterData SET MasterData.CompanyOpen = 1 WHERE
(((MasterData.Name)=""Sample Company 12-31-06""));"
End Sub
Sub UpdateMasterData2() <-----This sub does NOT update the table
correctly
Dim db As Dao.Database
Dim CompanyName As String
CompanyName = "Sample Company 12-31-06"
Set db = CurrentDb
db.Execute "UPDATE MasterData SET MasterData.CompanyOpen = 1 WHERE
(((MasterData.Name)="" & CompanyName & ""));"
End Sub