KAZZANeedsHelp
Technical User
I have a database created on access 2000.
I have a form called aDataManipulationF.
This form has a sub form on it called aStaffTrainingUpdateIndividuallyF.
The sub form opens ready to add a new record.
On this sub form I have a field called SSDetailsID which has a default value of 0 (zero). It is the first tab field on the report and data is required to be entered into this field.
This field has a LostFocus Event Procedure which I have written as follows (but it does not work the way I want):
***********************
Private Sub SSDetailsID_LostFocus()
On Error GoTo Err_SSDetailsID
Dim db As DAO.Database
Dim rs As DAO.Recordset
If Me.SSDetailsID = "0" Then
MsgBox "You must select Staff Site Details ID before moving on"
DoCmd.CancelEvent
SSDetailsID.SetFocus
End If
Exit_SSDetailsID:
Exit Sub
Err_SSDetailsID:
MsgBox Error$
Resume Exit_SSDetailsID
End Sub
**************************
What I want to do is to tell the user that "You must select Staff Site Details ID before moving on". I have done this through the use of a MsgBox which looks at whether there is a zero in the field. This works.
If there is a zero then they should not move on. I want the cursor to stay in the SSDetailsID field. This part of my code does not work. I have tried cancelling the event and setting the focus back to the field to no avail.
The other problem at the moment (as the code is written above) is if I click on the record selector (at the bottom of the form) the MsgBox shows up again. Apart from the irritation of the message showing up it does not stop the user from scrolling through previously created records (which is a good thing as I want the user to be able to scroll through previous records).
WHAT I NEED IS CODE THAT:
Gives the user an error message if the SSDetailsID field is = 0 (zero) and for the cursor to remain in the SSDetailsID UNLESS they click on the record selector, then it should allow them to scroll through previous records (without giving the initial error message.
I hope I have expained myself well enough here.
Can anyone help me?
Kazza
I have a form called aDataManipulationF.
This form has a sub form on it called aStaffTrainingUpdateIndividuallyF.
The sub form opens ready to add a new record.
On this sub form I have a field called SSDetailsID which has a default value of 0 (zero). It is the first tab field on the report and data is required to be entered into this field.
This field has a LostFocus Event Procedure which I have written as follows (but it does not work the way I want):
***********************
Private Sub SSDetailsID_LostFocus()
On Error GoTo Err_SSDetailsID
Dim db As DAO.Database
Dim rs As DAO.Recordset
If Me.SSDetailsID = "0" Then
MsgBox "You must select Staff Site Details ID before moving on"
DoCmd.CancelEvent
SSDetailsID.SetFocus
End If
Exit_SSDetailsID:
Exit Sub
Err_SSDetailsID:
MsgBox Error$
Resume Exit_SSDetailsID
End Sub
**************************
What I want to do is to tell the user that "You must select Staff Site Details ID before moving on". I have done this through the use of a MsgBox which looks at whether there is a zero in the field. This works.
If there is a zero then they should not move on. I want the cursor to stay in the SSDetailsID field. This part of my code does not work. I have tried cancelling the event and setting the focus back to the field to no avail.
The other problem at the moment (as the code is written above) is if I click on the record selector (at the bottom of the form) the MsgBox shows up again. Apart from the irritation of the message showing up it does not stop the user from scrolling through previously created records (which is a good thing as I want the user to be able to scroll through previous records).
WHAT I NEED IS CODE THAT:
Gives the user an error message if the SSDetailsID field is = 0 (zero) and for the cursor to remain in the SSDetailsID UNLESS they click on the record selector, then it should allow them to scroll through previous records (without giving the initial error message.
I hope I have expained myself well enough here.
Can anyone help me?
Kazza