On the OnClick event of a checkbox I have the following code:
Dim strState As String
Dim strEvent As String
Dim varYear As Variant
Dim strFinal As String
strState = Forms!frmLogCriteria!cboState
strEvent = Forms!frmLogCriteria!cboEvent
varYear = Forms!frmLogCriteria!cboYear
If (Not IsNull(strFinal = DLookup("[FinalFile?]", "tblLogs", "[State]= '" & strState & "'" & _
" and [Event]= '" & strEvent & "' and [Year]= '" & varYear & "'" & _
" and [FinalFile?]= -1"))) = True Then
MsgBox "There is already a shipment marked as final file."
chkFinalFile = 0
End If
What I want the code to do is bring up a message box if the Final file field is checked for an already existing record. If the Final file field is not checked then the user should be allowed to place a checkmark in this field. The problem is that sometimes the message box appears regardless if the final file field is checked or not in the table. I've tested the code in a separate subroutine and it works fine. But it does not work on the OnClick event. I've tried moving the code to the BeforeUpdate and AfterUpdate events and it still does not work properly. Does anyone have any other suggestion that I might try. I'm using MS Access 2003.
Dim strState As String
Dim strEvent As String
Dim varYear As Variant
Dim strFinal As String
strState = Forms!frmLogCriteria!cboState
strEvent = Forms!frmLogCriteria!cboEvent
varYear = Forms!frmLogCriteria!cboYear
If (Not IsNull(strFinal = DLookup("[FinalFile?]", "tblLogs", "[State]= '" & strState & "'" & _
" and [Event]= '" & strEvent & "' and [Year]= '" & varYear & "'" & _
" and [FinalFile?]= -1"))) = True Then
MsgBox "There is already a shipment marked as final file."
chkFinalFile = 0
End If
What I want the code to do is bring up a message box if the Final file field is checked for an already existing record. If the Final file field is not checked then the user should be allowed to place a checkmark in this field. The problem is that sometimes the message box appears regardless if the final file field is checked or not in the table. I've tested the code in a separate subroutine and it works fine. But it does not work on the OnClick event. I've tried moving the code to the BeforeUpdate and AfterUpdate events and it still does not work properly. Does anyone have any other suggestion that I might try. I'm using MS Access 2003.