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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

main form linked to subform with message

Status
Not open for further replies.

khicon73

MIS
Jan 10, 2008
36
Hello everyone,
I have a main form and a subform linked on ONE TO MANY with an "CUSTOMID". For instance,

On main form:
CustomID:15, DateReport:10/20/2008

On Subform:
CustomID: 15 , DateCollected: 10/10/2008
and some other field.

When the user enter a date into "DateCollected" on the subform is greater than "DateReport" on the main form, I would like to pop up a message and say "[DateCollected] can not be greater than [DateReport]. Please re-enter" (Example, if I enter "DateCollect" = "11/06/2008" and a message will pop up)

And after hit OK on the pop up message box, I would like to set [DateCollected[ = "" and DateCollected.SetFocus.

It can not move to the next record on the subform if "DateCollected" is blank or either "DateCollected" is greater than "DateReport" on the main form.

Please help, thank you very much.


 
Maybe something like this:

Code:
Private Sub Field1_AfterUpdate()

'Compare the value on MainForm with subform
If Me.Parent.DateReport < Me.DateCollected Then
    
    'Set message
    MsgBox "Your Message", vbOKOnly
    
    'Set focus to another control before setting it to desired field.
    Me.ID.SetFocus
    Me.DateCollected.SetFocus
End If

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top