bland fields

L

LG

I have a form and many times they exit out and don't finish entering info
therefore causing blank fields and addtional records. I know I need some
kind of null value but where do I start and where would I place it?

Ex form has id, fname, lname, address , zipcode, city, state. I would like
it to ensure we have atleast lname and address before it saves anything.
 
J

John W. Vinson

I have a form and many times they exit out and don't finish entering info
therefore causing blank fields and addtional records. I know I need some
kind of null value but where do I start and where would I place it?

Ex form has id, fname, lname, address , zipcode, city, state. I would like
it to ensure we have atleast lname and address before it saves anything.

Use the Form's BeforeUpdate event. Click the ... icon by the BeforeUpdate
event on the form's properties Events tab and choose Code Builder. Edit the
code to something like

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim strNag As String
If Me!Address & "" = "" Then
strNag = strNag & "Address "
End If
If Me!Zipcode & "" = "" Then
strNag = strNag & "Zipcode "
End If
<etc through the fields you want required>
If Len(strNag) > 0 Then
Cancel = True
MsgBox "Please put data into the following fields: " & strNag, vbOKOnly
End If
End Sub
 
J

John Spencer MVP

Open up the table in design view and set the fields' required property to Yes
for LName and Address. That way there is no way a record will be saved unless
those two fields have a value.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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