required field

  • Thread starter Christopher Glaeser
  • Start date
C

Christopher Glaeser

Some of our users are not setting one of the fields in our table, so I set
the Required property of the field in the table design. However, I am still
able to fill forms and save records without setting this field. The field
is type number, is used as an index to another table, and is set via a combo
box in the form, it that matters. Version is Access 2003.

Best,
Christopher
 
C

Christopher Glaeser

I found the following code which is working pretty well.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Fax) Then
' warn the user
MsgBox "Enter a Fax Number"
' send the user back to the correct control
Me.Fax.SetFocus
' and prevent the form going ahead with the update
Cancel = True

Next, I have to enhance error recovery to avoid multiple warning messages.

Best,
Christopher
 
G

Graham Mandeno

Hi Christopher

Something is amiss here. If you set the Required property on a field in
your table, then Access should refuse to save a record which has a Null
value in that field.

I suggest you double-check your property settings.

The BeforeUpdate event procedure you are using is a good idea *in addition
to* the Required property, because it gives you the opportunity to present
the user with a more helpful message that the built-in one.
 
C

Christopher Glaeser

Something is amiss here. If you set the Required property on a field in
your table, then Access should refuse to save a record which has a Null
value in that field.

I suggest you double-check your property settings.

You're right. The default property was set. Thanks.

- Christopher
 

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