T
Tom
Hi
I have been working with Access for a number of years but grope in the dark
as far as VBA is concerned (ie, don't know a lot).
I am developing a small application for reading barcode data for our factory
shop floor. The problem I am having is with one of the forms.
When the form is opened, focus is set on a text box called [OPERATOR_ID].
This is where the user scans their ID card resulting in their ID card number
and staff number being stored here. So far, so good.
On the 'On Exit' control, I have set some code to check to see if the
[OPERATOR_ID] and [CARD_STATUS] is valid. This also works fine.
The problem I have is that I want the user to be able to click on one of two
other buttons on the form: one to 'reset' the form so they can start again;
one to 'exit' the form. These buttons are called 'New_Entry_button' and
'exit' respectively. Without the code control on the [OPERATOR_ID] text box,
these also work fine. However, with the code in place, the user cannot get
past the [OPERATOR_ID] box: ie, unless they have entered a valid operator
number, they cannot click on the 'New_Entry_button' or the 'exit' button as
they just get the error message from exiting the [OPERATOR_ID] box and focus
is returned there. The coding I have used on the [OPERATOR_ID] box's 'On
Exit' control is as follows.
============
Private Sub OPERATOR_ID_Exit(Cancel As Integer)
If IsNull(Me!OPERATOR_ID) Then
MsgBox "You Cannot Proceed Without Entering An Operator Number"
Me!OPERATOR_ID.SetFocus
DoCmd.CancelEvent
ElseIf Me!CARD_STATUS <> "A" Or IsNull(Me!CARD_STATUS) Then
MsgBox "Illegal Card or Card Status Inactive - Contact Administrator"
Me!OPERATOR_ID.SetFocus
Me!OPERATOR_ID = ""
DoCmd.CancelEvent
End If
End Sub
============
I was thinking of trying to test to see if one of the buttons has been
clicked but this is beyond my knowledge of VBA. I guessed this could be done
on the 'lost focus' control on [OPERATOR_ID].
Could someone help me with this please?
Regards
Tom
I have been working with Access for a number of years but grope in the dark
as far as VBA is concerned (ie, don't know a lot).
I am developing a small application for reading barcode data for our factory
shop floor. The problem I am having is with one of the forms.
When the form is opened, focus is set on a text box called [OPERATOR_ID].
This is where the user scans their ID card resulting in their ID card number
and staff number being stored here. So far, so good.
On the 'On Exit' control, I have set some code to check to see if the
[OPERATOR_ID] and [CARD_STATUS] is valid. This also works fine.
The problem I have is that I want the user to be able to click on one of two
other buttons on the form: one to 'reset' the form so they can start again;
one to 'exit' the form. These buttons are called 'New_Entry_button' and
'exit' respectively. Without the code control on the [OPERATOR_ID] text box,
these also work fine. However, with the code in place, the user cannot get
past the [OPERATOR_ID] box: ie, unless they have entered a valid operator
number, they cannot click on the 'New_Entry_button' or the 'exit' button as
they just get the error message from exiting the [OPERATOR_ID] box and focus
is returned there. The coding I have used on the [OPERATOR_ID] box's 'On
Exit' control is as follows.
============
Private Sub OPERATOR_ID_Exit(Cancel As Integer)
If IsNull(Me!OPERATOR_ID) Then
MsgBox "You Cannot Proceed Without Entering An Operator Number"
Me!OPERATOR_ID.SetFocus
DoCmd.CancelEvent
ElseIf Me!CARD_STATUS <> "A" Or IsNull(Me!CARD_STATUS) Then
MsgBox "Illegal Card or Card Status Inactive - Contact Administrator"
Me!OPERATOR_ID.SetFocus
Me!OPERATOR_ID = ""
DoCmd.CancelEvent
End If
End Sub
============
I was thinking of trying to test to see if one of the buttons has been
clicked but this is beyond my knowledge of VBA. I guessed this could be done
on the 'lost focus' control on [OPERATOR_ID].
Could someone help me with this please?
Regards
Tom