Required fields, "PLEASE ENTER IN THIS FIELD", IT IS REQUIRED. HELP PLEASE

jenny23

Registered User.
Local time
Today, 06:57
Joined
Apr 1, 2004
Messages
47
HEllo friends,
I have this question: I have a data entry form.
How do I protect users from skipping fields on the forms? I mean, how do I make sure that a certain field must be filled by user? (required field).
I am new wit ms access, please help.
Example: I have 3 fields on a form, student-id, name, class... they are all required fields. When users fill on the student-id, then move to the name field but don't enter anything, then move to class field. I want a message like this: "please enter on the name field, it is required"

PLEASE HELP.

THANKS
 
Hi
I use this sort of code
Code:
    If IsNull(Me.txtDoseQc) Or Me.txtDoseQc = "" Then
            MsgBox "You must enter a quick code for the dose", vbOKOnly, "Required data"
            Me.txtDoseQc.SetFocus
        Exit Sub
    End If
You simply rename it to the textbox names on your form. You can also customise the message to what you want, polite or otherwise!
I think you will find it solves the problem.
I tend to put it at the start of the code on the command button when you have finished the form so it checks to see if each required entry is valid but you could put it (I think) in the lost focus event for the textbox.
Hope this helps

Malcy
 
Use the BeforeUpdate event of the form to Cancel the update if fields have not been entered
 
Malcy,

Is there a way to do that with two cascading combo boxes?

ie, if, after entering a value in the first combo box, it turns out no values in the second combo box, a msgbox pops up saying, "no values were returned" or something like that?

I tried the code you used above and substituted the name of my combo box where the name of the txt box was, but it didn't work.

binghamw
 
It doesn't work

I tried both the lost focus and before update event, it shows an error.
My field is not text box, but a combo boxes. Does it make a difference?

Thanks.
 
Thanks Pat about the Lost Focus bit. I will remember that - it was just a longshot and not one I have used.

Also Jenny, worth making sure that you have called the combo box up properly so that when you enter Me. it should come up with a list of your controls. For a long time I used to call them the same as the field but gradually learned to prefix textboxes with txtWhatever and combo boxes with cboWhatever so it becomes much easier to see where it is going wrong.
Best wishes

Malcy
 

Users who are viewing this thread

Back
Top Bottom