Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable record navigation

Status
Not open for further replies.

shart00

Technical User
Jun 16, 2003
63
US
Hoping for some help. I have a form setup that require some fields to be entered. I have written some code that does not allow the user to exit the database unless the fields are filled in and unfortunately the code conflicts with setting the field to "Required" in the table.

What I'm trying to do is not allow an operator to change records until the current record is complete or deleted. I have disabled the record navigation buttons but you the operator can still do a search or use the scrolling mouse to change records without these "required fields" being entered. Anyone have an idea of how to prevent this from happening? Something like an event when the record losses focus the code will verify the fields are not null, if they are null then display a message.

Thanks, shart00
 
shart00
You could put code on the BeforeUpdate event of your form.
Here is an example that I have in a Payments form, which alerts the user if a PaymentType has been omitted and/or the Amount is not entered.

If IsNull(PaymentType) Then
MsgBox "Please select a Payment Type!", vbExclamation
PaymentType.SetFocus
Cancel = True
ElseIf (Amount) = 0 Then
MsgBox "Please select an Amount greater or less than $0.00!", vbExclamation
Amount.SetFocus
Cancel = True
End If

Hope that helps.

Tom
 
Thanks, I tried it out but I'm still able to switch records by using the scroll mouse. I've tried a few different events but none of them seem to work. Any other ideas? I'm stumped.
 
shar00:

You can disable the navigation buttons in code. I'm not positive on the syntax but this might work:

Me.NavigationButtons = False

Put this in the On Current Event so it triggers whenever the record changes.

Put Me.NavigationButtons = True in the event where you are doing the edit checking.

Of course, if the user enters a record and does not invoke the edit code, the navigation buttons will remain unavailable.

Personally, I use custom navigation buttons and hide them when the user is entering a new record or editing an old one. I also disable the controls for adding a new record and closing the form and I set the cycle to current record so the user can't tab into the next.

If you are interested in the code for this, I have a sample database I can zip up and send to you. Just let me know if you need a 97 version or 2K/later.

Hope this helps.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top