I am attaching this code to the onload event of a form bound to a table.
And i want it to check a chkbox on this form if some data on this form (Text18, txtResource) exits in "another" tiny table ([Weekending], [sID]).
Here is what i have at the onload event:
However, i get this error: When i load my form.
Any thoughts or suggestions? What am i doing wrong?
And i want it to check a chkbox on this form if some data on this form (Text18, txtResource) exits in "another" tiny table ([Weekending], [sID]).
Here is what i have at the onload event:
Code:
On Error GoTo Err_ChkBox_Click
Dim db As DAO.Database
Set db = CurrentDb()
Dim MySQL As String, DQ As String
DQ = """"
MySQL = "SELECT [WeekEnding] from tblNoSupportHrs WHERE [sID] = " & DQ & Me.txtResource & DQ & _
" And [WeekEnding] = " & DQ & Me.Text18 & DQ & ";"
If Me.Text18 = MySQL Then
Me.chkNoSupportHrs = True
Else
End If
db.Execute MySQL, dbFailOnError
Exit_ChkBox_Click:
Set rs = Nothing
Set db = Nothing
Exit Sub
Err_ChkBox_Click:
MsgBox "Error No: " & Err.Number & vbCr & _
"Description: " & Err.Description
Resume Exit_ChkBox_Click
End Sub
However, i get this error: When i load my form.
Any thoughts or suggestions? What am i doing wrong?