Data Validation To Prevent No Entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form which i used to collect data used by an update query. When I
click a button on the form I trigger a macro that opens the query. The form
passes parameters to the query. When the button is pressed I want to validate
that an entry has been made in a specific text box. I have tried various
things to trigger the validation rule but none seem to work. The validation
rule only seems to trigger if you make an entry in the text box. How do I
trigger the validation rule?
 
If your form is bound to a datasource, you could use the BeforeUpdate()
event on the form (see help file for more specific details).
Otherwise, you could do the validation check right there on the button.

For example:

Private Sub Button1_Click()

If Me.txtFirstName = "" Then
MsgBox "Before you proceed, please enter a first name."
Else
' Call the macro here
End If

End Sub

--
Rob Mastrostefano

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
 
Thanks for the tip. I got it working. However I had to use IsNull(Me.Field)
rather than Me.Field = ""
 
Back
Top