Help

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

Ok, I have created a form with various fields. I would like to make certain
fields required information. In other words a certain field would require
you to put information into before you can close the form or move to the
next field.

thanks for you help
 
Ok, I have created a form with various fields. I would like to make certain
fields required information. In other words a certain field would require
you to put information into before you can close the form or move to the
next field.

thanks for you help

Two ways (at least) to do this:

- Open the Table which will contain this data and select each of these
fields; set the field's Required property to True.

- For a friendlier error message, use the Form's BeforeUpdate event.
Invoke the Code Builder and put code like

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If IsNull(Me!txtReqFieldA) Then
iAns = MsgBox("Please fill in Field A; or Cancel to clear form", _
vbOKCancel)
If iAns = vbOK Then
Cancel = True ' cancel the update to the table
Me!txtReqFieldA.SetFocus ' move the user to the control
Else
Me.Undo ' erase the entire form to start over
Cancel = True
End If
End If
End Sub
 

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

Back
Top