+ Reply to Thread
Results 1 to 6 of 6

Only show msgbox once

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Only show msgbox once

    Hi All

    I have a calculator built as a userform into one of my workbooks, upon opening the userform (calculator) a msgbox is prompted which reminds the user which textboxs to fill in, and let the others do the calculation, this is handy to have at the beginning, but my issue is that it is always there any time you unload, clear, ok, etc.

    All i want the user to do is acknowledge the mesgbox, gain access to the calculator, then clear their figures out each time and start again until the exit the userform.

    Once the userform has been closed, then if they click on the command button to open the userfrom the msgbox will show again then

    Any ideas?

    Dan

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    01-28-2013
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    50

    Re: Only show msgbox once

    I'm not sure you need to go through the if statement if all you want to do is show the message and then have the user OK it.

    From what I can see, you should just be able to use the following code.

    Please Login or Register  to view this content.
    Please consider the * button if my post helped you

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Only show msgbox once

    Hi bodhi808

    Thank you i have tried this but it still shows the msgbox every time the userform is cleared and reset, i want it to show only on the initial start up of the userform then not again until the user exits the userform and has to use the command button to get back into it.

    Dan

  4. #4
    Registered User
    Join Date
    01-28-2013
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    50

    Re: Only show msgbox once

    Presumably then each time the userform is cleared or reset it re-runs the initialize code?

    One way around this would be to declare a public variable in your main module which you can check before displaying the message box.

    So at the top of Module 1 add the line:
    Please Login or Register  to view this content.
    Then alter the userform initialize code to:
    Please Login or Register  to view this content.
    Finally, add a line to the code which closes the calculator user form (not the code to reset or clear it):
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Only show msgbox once

    Cheers bodhi808, i will have a look and play around with it, after my first try it keeps coming up with a run error, but may be im missing something, il have a go with the code you have shown above and see what im missing/ putting in the worng place

    Thanks

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Only show msgbox once

    Hey, I figured it out

    I took away the msgbox from the userform_initialise

    and added it to the commanbutton_click, Where the userform generates from, that way i figured the msgbox would only ever show when the user clicks the command button, rather than clearing, reseting, or re-initialising the userform

    Hey presto it works

    Althought this VBA stuff is extremly hard sometimes, and fairly difficult to understand at first, some things seem so easy it just takes a little bit of thought

    Thanks for your help, i wouldnt of realised if i wasnt playing around with the code you gave me

    Dan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1