Make field required

S

stockwell43

Hello,

I have two fields on my form that I need to make required before the user
can add record. I went into the table and in Required I changed it to Yes for
both fields and works fine. However, the trouble I am having is when the pop
up form shows it only says "You cannot go the the specific record". How do I
get the pop to show which field needs to be complete before they can add the
record? I have a Creation Date field (fCurrentDate) and a Keyword field
(fKeywords)

Any help would be most appreciated!!!

Thanks!!
 
J

Jeff Boyce

If you:
1. created the table
2. created the form, bound to the table
3. modified the table to make those fields required

Access may not know that the form's underlying fields have been modified.
Consider either re-creating the form (much work) or using design view on the
form to make those two controls "Required" (easier).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

stockwell43

So basically, are you saying VBA? If so how would I code it? If not, how do I
do it?

I have created the table
I have created the form, bound to the table
In the table I selected Yes where it says required.

In vba, could I get code something behind current form to know if those two
field have been completed? I would like it where if both are null, when the
first message appears and the user clicks ok, the second one appears with the
other field that needs to be completed.

Any help would be appreciated!!!

Thanks!!!
 
J

Jeff Boyce

Yes, one way to handle the validation of the record is through a procedure
you add to the record's BeforeUpdate event.

Another, less user-friendly, approach is to add a validation rule that
doesn't allow a Null (i.e., Is Not Null) for each/both controls. You can
add Validation Text to display if the validation rule is triggered (but this
is neither as flexible nor as friendly as using VBA).

Open the BeforeUpdate event and add your testing/messages.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

stockwell43

Do you think you might be able to give me the code I need to make this
happen? Because I really am not sure about everything your referring to and
it would be much easier for me and I can save for if I ever need it again.

If not, I understand and I suppose I could re-post.

Thanks!!!!
 
J

Jeff Boyce

"How" depends on "what". You'll need to provide the name of the form, and
the name of the controls.

.... and if/when it doesn't work, you'll need to trouble-shoot the procedure,
too. Got VBA?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

stockwell43

Ok, here is the info:

Form Name is:

FAQ Details

Field Names are:

fCurrentDate and fKeywords
 
J

Jeff Boyce

A caution ... if you're going to use code/VBA, how will you know if it does
what it needs to (and ONLY what it needs to)? One way or the other, you
will need to spend some time learning about VBA...

Here's some untested aircode to put into an event procedure for the form's
BeforeUpdate event:

If Nz(Me![fCurrentDate],"") = "" Then
Cancel = True
Me![fCurrentDate].SetFocus
MsgBox "An entry is required in the Current Date field", vgOKOnly,
"Cancelling ..."
End If

If Nz(Me![fKeywords],"") = "" Then
Cancel = True
Me![fKeywords].SetFocus
MsgBox "An entry is required in the Keywords field", vgOKOnly,
"Cancelling ..."
End If

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

stockwell43

WOW!!!!!!

This is some very serious air code my man!!!! Works like a charm and I thank
you very much for your help!!!!!

I do know a little VBA but I am better at manipulating what's there to suit
my needs than to write it from scratch. I save all the code I get from this
board and use it when creating other databases. I have a lot of book but they
are for 2003 and I think we are going to 2007 by the end of the year.

Thank you again for you help, it's most appreciated!!!!

Jeff Boyce said:
A caution ... if you're going to use code/VBA, how will you know if it does
what it needs to (and ONLY what it needs to)? One way or the other, you
will need to spend some time learning about VBA...

Here's some untested aircode to put into an event procedure for the form's
BeforeUpdate event:

If Nz(Me![fCurrentDate],"") = "" Then
Cancel = True
Me![fCurrentDate].SetFocus
MsgBox "An entry is required in the Current Date field", vgOKOnly,
"Cancelling ..."
End If

If Nz(Me![fKeywords],"") = "" Then
Cancel = True
Me![fKeywords].SetFocus
MsgBox "An entry is required in the Keywords field", vgOKOnly,
"Cancelling ..."
End If

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP



stockwell43 said:
Ok, here is the info:

Form Name is:

FAQ Details

Field Names are:

fCurrentDate and fKeywords
 

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