Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

MsgBox prompt on exit from tabbed form

Posted on 2004-11-05
9
Medium Priority
?
368 Views
Last Modified: 2012-08-13
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?

0
Comment
Question by:wduffus
7 Comments
 
LVL 3

Expert Comment

by:leeskelton83
ID: 12509654
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
 

Author Comment

by:wduffus
ID: 12509682
No, I'm just clicking on another of the main form tabs.
0
 
LVL 3

Expert Comment

by:leeskelton83
ID: 12510068
Then try to put it on the OnDeactivate event.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:wduffus
ID: 12510519
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
 
LVL 3

Expert Comment

by:leeskelton83
ID: 12514408
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
 
LVL 6

Accepted Solution

by:
Plamodo earned 252 total points
ID: 12515969
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
 
LVL 39

Assisted Solution

by:stevbe
stevbe earned 248 total points
ID: 12517112
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question