Simple Button Problem

moagli

Registered User.
Local time
Today, 07:50
Joined
Nov 17, 2006
Messages
15
I have a database with a form in it, i dont want to use the automatic buttons to go back and forth through records because i need it to run an if statement even time it is pushed, the problem is i need to include provision for errors with the button. This is the code i have so far:

Private Sub Command32_Click()

DoCmd.GoToRecord , , acNext
If Me.Type_of_care = "other" Then
Me.Insurance_code.Enabled = False
ElseIf Me.Insurance_code = " " Then
Me.Insurance_code.Enabled = False
Else: Me.Insurance_code.Enabled = True
End If

End Sub

The docmd command is to just get the next record, the if statement checks to see whether an iput box is enabled it very simple atm. The problem is that when a problem occurs, it goes to the debug menu, this is a problem for my end user as they have limited computer skills.

Thank in advance.
 
i dont want to use the automatic buttons to go back and forth through records because i need it to run an if statement even time it is pushed,

run your code from the currnent event of the form and you can use the standard buttons without needing to create your own.

you will still need to add error trapping to you code, but just what you need will depend on what is causing the errors!

one possible one is 'Me.Insurance_code.Enabled = False' if this code runs when field has the focus it will through an error, so check if it has focus first and if it does move the focus to a safe field.

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom