Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required field help!!!! 1

Status
Not open for further replies.

PLK3541

IS-IT--Management
Mar 29, 2005
60
0
0
US
Hey All,

I am very new at this and could use a hand. I have an Access form that was created to potential job and client information. The form has two sub-forms, one for client info and the other for when the potential becomes a job.
I need to make some of the fields in the form required and don’t want to do this at the table level.

There is no submitting or save record button to place code in any event. I close the form by closing the database. I would like to have it that if the required field is null then a message box that let them know what field and then set focus to the field.


I tried using this code but it will give me the message box then when I click OK it just close the form.


Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me. PotentialDate) Then
Cancel = True
MsgBox "You must enter a Surname."
Me. PotentialDate.SetFocus

Else
DoCmd.Close acForm, "JobPotentialForm

End If
End Sub


This if statement did not work for me either, not sure where to place code


if Isnull (me. PotentialDate) then

Msgbox "Please Enter Data...", vbokonly, "This fields is required:"

me.[ PotentialDate].setfocus

end if

Thanks for your help in this matter.
 
Have you seen this (?):
KISS way to force users to click a command button to exit a form regardless of menu or toolbar options
faq702-2071
 
How are ya PLK3541 . . .

Have a look at the forms [blue]BeforeUpdate[/blue] property and particular attention to the [blue]Cancel[/blue] arguement! . . .

Calvin.gif
See Ya! . . . . . .
 
Thanks Remou, I'll use that sometime. Star from me, and credit to the writer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top