Hello,
I am new to this posting stuff, but here is my current dilema . . . .
I have a checkbox in one of my tables and I need for it to update using an update query. Now using straight Access I can just say UPDATE tblname.checkbo xfiled=Yes or even -1 and I get the good result.
The problem is I am using ome VBA coding and it doesn't seem to like the =Yes or =-1. I tried putting them in single quotes and I get a data conversion error.
My code is as follows:
[CODE=vb]Private Sub cmdRoleExists_C lick()
Dim DB As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set DB = CurrentDb()
Set qdf = DB.QueryDefs("q rySAPSecurityRo leExistsUpdate" )
For Each varItem In Me!lstSecurityS AP.ItemsSelecte d
strCriteria = strCriteria & "," & Me!lstSecurityS AP.ItemData(var Item)
Next varItem
If Len(strCriteria ) = 0 Then
MsgBox "You must select at least 1 SAP #" _
, vbExclamation, "No Selection Made"
Exit Sub
End If
strCriteria = Right(strCriter ia, Len(strCriteria ) - 1)
strSQL = "UPDATE tblTrackingData SET tblTrackingData .[SAP Security Role Status] = 'Completed - ' & Date(), tblTrackingData .[SAP Security Role] = Yes" & _
"WHERE tblTrackingData .[SAP #] IN(" & strCriteria & ")"
qdf.SQL = strSQL
DoCmd.OpenQuery "qrySAPSecurity RoleExistsUpdat e"
Set DB = Nothing
Set qdf = Nothing
End Sub
[/CODE]
When I remove the tblTrackingDAta .[SAP Security Role] = Yes part of the code (which is the checkbox field) the rest works just fine.
Any thoughts would be most appreciated.
Thanks!
I am new to this posting stuff, but here is my current dilema . . . .
I have a checkbox in one of my tables and I need for it to update using an update query. Now using straight Access I can just say UPDATE tblname.checkbo xfiled=Yes or even -1 and I get the good result.
The problem is I am using ome VBA coding and it doesn't seem to like the =Yes or =-1. I tried putting them in single quotes and I get a data conversion error.
My code is as follows:
[CODE=vb]Private Sub cmdRoleExists_C lick()
Dim DB As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set DB = CurrentDb()
Set qdf = DB.QueryDefs("q rySAPSecurityRo leExistsUpdate" )
For Each varItem In Me!lstSecurityS AP.ItemsSelecte d
strCriteria = strCriteria & "," & Me!lstSecurityS AP.ItemData(var Item)
Next varItem
If Len(strCriteria ) = 0 Then
MsgBox "You must select at least 1 SAP #" _
, vbExclamation, "No Selection Made"
Exit Sub
End If
strCriteria = Right(strCriter ia, Len(strCriteria ) - 1)
strSQL = "UPDATE tblTrackingData SET tblTrackingData .[SAP Security Role Status] = 'Completed - ' & Date(), tblTrackingData .[SAP Security Role] = Yes" & _
"WHERE tblTrackingData .[SAP #] IN(" & strCriteria & ")"
qdf.SQL = strSQL
DoCmd.OpenQuery "qrySAPSecurity RoleExistsUpdat e"
Set DB = Nothing
Set qdf = Nothing
End Sub
[/CODE]
When I remove the tblTrackingDAta .[SAP Security Role] = Yes part of the code (which is the checkbox field) the rest works just fine.
Any thoughts would be most appreciated.
Thanks!
Comment