Good afternoon, folks. I have a table of users, tblAuthorizedUsers. In the table I have a text field, LogOn, and a checkbox, ApdCCD. I have a main form, and on that form I have a command button, for approval, and in the OnClick procedure I am try to run a validity test to see if the checkbox, for the current LogOn user, is true or not. When I click the command button, my logon entered in the textbox and todays date is entered in another, despite the fact that the checkbox ApdCCD is not checked for me. This is my OnClick code:
If DCount("[LogOn]", "tblAuthorizedUsers", "[LogOn]='" & fOSUserName() & "'"
= 0 Then
MsgBox "You Are Not an Authorized User."
Me.Undo
'Delete wrong entered users
Me!CCDApproved.SetFocus
'Re-Enter Approval, same field
Else
'Valid user test, Is a valid user
If DCount("[LogOn]", "tblAuthorizedUsers", "[ApdCCD] = True"
= 0 Then
MsgBox "You Are Not Authorized To Approve This Section."
Me.Undo
'Delete wrong section users
Me!CCDApproved.SetFocus
'Re-Enter Approval, same field
Else
'The User is Authorized
Me.CCDApprovedBy = fOSUserName()
'Enter LogOn in Approved By textbox
Me.CCDDate = Date
'Enter Today's Date in the Date textbox
Me.CCDComments.SetFocus
'Set Focus on Comment textbox
End If
End If
The first DCount statement is working correctly, it is the second Dcount statement that should be stopping me, because I do not have the ApdCCD checkbox checked, but it is not stopping me. Can anyone see what is wrong with this procedure? Thank you in advance for any assistance.
If DCount("[LogOn]", "tblAuthorizedUsers", "[LogOn]='" & fOSUserName() & "'"
MsgBox "You Are Not an Authorized User."
Me.Undo
'Delete wrong entered users
Me!CCDApproved.SetFocus
'Re-Enter Approval, same field
Else
'Valid user test, Is a valid user
If DCount("[LogOn]", "tblAuthorizedUsers", "[ApdCCD] = True"
MsgBox "You Are Not Authorized To Approve This Section."
Me.Undo
'Delete wrong section users
Me!CCDApproved.SetFocus
'Re-Enter Approval, same field
Else
'The User is Authorized
Me.CCDApprovedBy = fOSUserName()
'Enter LogOn in Approved By textbox
Me.CCDDate = Date
'Enter Today's Date in the Date textbox
Me.CCDComments.SetFocus
'Set Focus on Comment textbox
End If
End If
The first DCount statement is working correctly, it is the second Dcount statement that should be stopping me, because I do not have the ApdCCD checkbox checked, but it is not stopping me. Can anyone see what is wrong with this procedure? Thank you in advance for any assistance.