Set Focus

P

Pam

I have a main form "fGeneralInfo" with subform "fWorkLog" and subform
"fWorkLogComments". When user enters comments to subform fWorkLogComments
and they don't enter their name and date in fWorkLog.CboTech and
fWorkLog.StartTime, I want a msg to pop up telling them to do so and to set
the focus to CboTech and then StartTime if both are not filled in. I have
the following code on BeforeUpdate of the subform "fWorkLogComments". I
have entered may combinations of SetFocus and can get nothing to work. The
message will pop up, but if user clicks ok at each one, they will eventually
leave the form. I really need to have Tech and StartTimes required for
these entries.

I would very much appreciate any help with this.
Pam

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Parent.fWorkLog!Tech) Then
Cancel = True
MsgBox "Please enter your name."

End If

If IsNull(Me.Parent.fWorkLog!StartTime) Then
Cancel = True
MsgBox "Please enter date for this comment in Start Time."

End If
End Sub
 
P

Pam

Daniel,
Thanks for the reply. I tried this and received the message "Existing data
violates the new setting for the 'Required' property for field 'Tech'.
Pam

..
 
J

Jacob

Pam,

Some of the records may have no data (Null) in that field. Make sure
that the field has data in *all* recrods before you change the setting
to "Required=Yes"

Further, I suggest that in addition to Reuired, set "Allow Zero Length"
to "No", if the option is there..

Regards
Jacob
..
 

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

Similar Threads


Top