Full Version: disable validation on certain buttons
UtterAccess Forums > Microsoft® Access > Access Forms
CSturtevant
I am trying to disable form validation for certain buttons on a form - can somebody provide any code that will accomplish this? My coding abilities are very limited... thanks!
Bob_L
What "form validation" are you talking about?
CSturtevant
i have a bunch of text boxes that will be required, but i would like the user to be able to review previous records without having to fill in the text boxes - when the user is finished entering the data, they will hit a submit button that runs the validation. the problem is when they hit the form buttons to review data and they haven't finished entering the data on the current record, it won't allow them to navigate.
Bob_L
What you will need to do is to remove any validation (for example settings of REQUIRED at the table level). So, you can use the form's Before Update event for the validation. You don't need to disable validation, just move it to the correct spot.
theDBguy
Hi Bob,
hat's up with the yellow dot? confused.gif
Bob_L
It's the icon from my website grinhalo.gif
theDBguy
Thanks, Bob.
didn't realize you've updated your site. It looks really nice! thumbup.gif
CSturtevant
Thank you for the response.
I have removed all table level settings and have tried the following code:
Private Sub Form_BeforeUpdate()
If IsNull(Me.txtInputDate) Then
Me.txtInputDate.SetFocus
MsgBox "Please Enter a Date"
Cancel = True
End If
End Sub
However, I keep getting this error message: Procedure declaration does not match description of event or procedure having the same name.
I'm not sure what's going on here?
Thanks again
Bob_L
Did you type this in yourself:
Private Sub Form_BeforeUpdate()
Because it doesn't look like what it should look like if Access did it (which you should let it do).
CSturtevant
That was it - thanks!
Bob_L
CSturtevant
Is it possible to allow the validation check to only occur when they choose to submit the record? I would like for the user to be able to start another record, but it gives the error message when I try to start another record. I tried it out using the default buttons on the form...should I create my own buttons and then assign events to the buttons? Thank you
Bob_L
The before update event will happen if you try to go to another record. If you want to cancel the record then put a button that does:
e.Undo
to cancel any changes first
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.