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.
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.