MsgBox prompt on exit from tabbed form

I have a tabbed form in Access 2000.  When leaving my Call Activity tab, I want to generate a MsgBox reminding me to fill in a follow-up call date on the sub-form if the text field is null.  The present code (that doesn't work) is:

Private Sub Form_LostFocus()
    If txtCallBackDate Is Null Then
    MsgBox ("Do you want to set a call back date?"), vbYesNo, ("Schedule Callback")
        If vbYesNo = -1 Then
            Form_frmCallActivitySub.SetFocus
        End If
    Else
   
    End If
 
End Sub

Any ideas?

wduffusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leeskelton83Commented:
Are you closing the form with a command button? If so, paste your code to the OnClick event of it and it will run before it closes.
0
wduffusAuthor Commented:
No, I'm just clicking on another of the main form tabs.
0
leeskelton83Commented:
Then try to put it on the OnDeactivate event.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

wduffusAuthor Commented:
I tried the above code under Private Sub Form_Deactivate() in frmCallActivitySub and it doesn't work there either.  Is this supposed to be in my subform or the main form?
0
leeskelton83Commented:
Yes I see now. You may have to approach this a different way. Perhaps you can make your code run on the LostFocus or AfterUpdate event of a text box or other control. How is your form set up?
0
PlamodoCommented:
Wouldn't you want to put that code in the on_change event of the tab control?  I assume its a tab control we're talking about, eh?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stevbeCommented:
I would use the Exit event of the subform control itself which provides a way to Cancel the Exit ...

Private Sub Child5_Exit(Cancel As Integer)
    If txtCallBackDate Is Null Then
        If MsgBox ("Do you want to set a call back date?"), vbYesNo, ("Schedule Callback") = vbYes Then
            Cancel = True
        End If
    End If
End Sub

Steve
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.