Rerquired fields check with VBA

Coatezy

Registered User.
Local time
Yesterday, 16:46
Joined
Jan 8, 2009
Messages
39
Required fields check with VBA

Hi guys,

I am building a database at the moment that requires some required fields... Problem is the form needs to be refreshed before the form is completely filled in which makes access prompt the user that all required fields have not been filled in.. Instead of setting the table fields as required is there any way to use vba so that once the user clicks submit it checks each field has data in it and then allows it to be entered. If not it prompts them.

Cheers! :D
 
Last edited:
Depending on the number of fields we are talking about, would it not be possible for you to do a lengthy if statement on the submit button?

If me.field1 = "" then
me.field1.setfocus
else if me.field2 = "" then
'carry this on for X number of fields
end if

'save your record and close
 
Depending on the number of fields we are talking about, would it not be possible for you to do a lengthy if statement on the submit button?

If me.field1 = "" then
me.field1.setfocus
else if me.field2 = "" then
'carry this on for X number of fields
end if

'save your record and close

So lets say I want to check field Me.JobNo what would I need to enter in the code above!? I tried what I though It should be but not working :( Thanks for your help! :cool:
 
I take it the JobNo is a number field?
If so it will be

if me.jobno = 0 then
 
Ok sorry, that's only actually true if your table has a default value of 0 for the field. otherwise do this.

me.jobno.setfocus
if me.jobno.text = "" then
msgbox "Fill in"
end if
 

Users who are viewing this thread

Back
Top Bottom