Data Validation To Prevent No Entry

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?
 
R

RobFMS

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
 
G

Guest

Thanks for the tip. I got it working. However I had to use IsNull(Me.Field)
rather than Me.Field = ""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top