Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2006, 10:36 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default MsgBox in Enter Event does not allow update

OK I tried asking in the Microsoft forums and no luck. I have a multipage (mpgLogs) on a form with three pages. I change which page to display based on the value of a combobox. I want to make sure the user wants to change the combobox value because I will delete control values on other pages of the multipage. So I show a msgbox with vbYesNo.

If they click No, I want to keep the same combobox value and don't change the multipage. If they click Yes, clear multipage values and change the multipage to the page selected in the combobox.

When the user clicks yes and then clicks a new value in the combobox the following events fire: 1) down button click 2) mouse down, 3) mouse up. No change event. The value of the combobox stays at the original value. Why don't the change, click events fire?

I do not want to use the Before or AfterUpdate events because the user has to move from the combobox before they fire. I want the check before.

Thanks for any help you can give.

Private Sub cbLogType_Enter()
    Dim stMsg, stTitle As String
    Dim iResponse, iStyle As Integer

    ' Define message.
    stMsg = "Are you sure you want to change the Log Type?" + vbCrLf
    stMsg = stMsg + "Clicking Yes will delete all previous values." + vbCrLf
    stMsg = stMsg + "Click Yes to change and No to keep the same Log Type?"
    ' Define buttons.
    iStyle = vbYesNo + vbQuestion
    ' Define title.
    stTitle = "Cancel Log Type Change?"

    ' Display message.
    iResponse = MsgBox(stMsg, iStyle, stTitle)

    If iResponse = vbNo Then
        ' User chose No so just change focus so that cbLogType does not change
        mpgLogs.SetFocus
    Else
        'don't think this is necessary because i will change multipage when change event fires
    End If
End Sub
 
Old March 8th, 2006, 10:36 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use Click Event

 
Old March 8th, 2006, 10:43 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Click event runs after the change event so that won't work. I want to warn them before they change the value.

For a combobox the events run
enter
mouse down
drop button click
mouse up
mouse down
mouse up
change
click
drop button click
before update
after update
exit

Quote:
quote:Originally posted by peko
 Use Click Event






Similar Threads
Thread Thread Starter Forum Replies Last Post
ToolStripMenuItem Enter & Leave Event angelboy C# 2005 6 November 21st, 2008 04:57 PM
Removing the MsgBox in DoCmd.RunSQL Update arfa Access 2 March 24th, 2006 08:05 PM
Pressing Enter should fire an event r_ganesh76 ASP.NET 1.0 and 1.1 Professional 4 September 28th, 2004 12:02 AM
Enter Key event handler KevinO ASP.NET 1.0 and 1.1 Basics 2 August 17th, 2004 09:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.