I get a 3061 runtime error with the following code. I'm assuming the UPDATE query is not recognizing "ChkBox" as a variable string containing the field name. If that is in fact the case, what's the syntax required so that the "ChkBox" string is understood as a field name?
Code:
Private Sub SetTable(ChkBox As String)
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' From the name of the check box control, we can determine which column and
' hense which table and field needs to be initialized.
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
On Error GoTo Err_Handler
Select Case left(ChkBox, 4)
Case "ck11": CurrentDb.Execute "UPDATE tblCol1 SET chkbox = True" 'User number 1, period 1
Case "ck12": CurrentDb.Execute "UPDATE tblCol2 SET chkbox = True" 'User number 1, period 2
Case "ck21": CurrentDb.Execute "UPDATE tblCol3 SET chkbox = True" 'User number 2, period 1
Case "ck22": CurrentDb.Execute "UPDATE tblCol4 SET chkbox = True" 'User number 2, period 2
End Select
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " attempting to initialize column table : " & Err.Description
Resume Exit_Handler
End Sub