Requiring Data in form fields

M

magmike

I have three fields I would like to require:

[County] a text box
[PCompany] a combo box that gets its data from another table
[MList] a yes/no radio group

Using the information found in an old post
(I tried the following in the
form's properties under BeforeUpdate:
--------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.MyCompany) Then
Cancel = True
MsgBox "You forgot 'My Company'!"
End If
End Sub
--------

First problem is, that it doesn't seem to work. If I start a new record and
enter data, failing to make a selection from the PCompany combo box, it
doesn't alert me. Secondly, once I do get something to work, if I am using
this under the form's properties, instead of under the control's, how can I
modify it to apply to all three controls?
 
M

magmike

My apologies - I DID get the Sub to work. At the table level, Default Value
was set as 0. Erased that and it now works.

HOWEVER,

I still would like to modify the sub so that it checks the other two form
fields. Also, How can I get it to automatically put the cursor to the first
field it checks, and then warn about each other field (if applicable) only
after an update is reattempted?

Thanks a bunch!
Mike
 

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