Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297

    Unanswered: Dynamic MsgBox that won't pause the script

    Hi guys,

    Just a quick one really...

    I'm doing a large import, and manipulation through various ODBC's, and to the backend of the DB. The entire process can take anywhere between 2 and 10 minutes, depending on the criteria specified by the end user.

    What I want, is at various stages of my script to have a window pop up, explaining what process is currently active, without requiring the user to click anything (Ok, for example). I also don't want the script to stop running, which MsgBox will do.

    So for example, when the main import button is clicked, windows should appear saying the following:

    Importing...
    Transferring...
    Weeding out loose ends...
    Finalising...
    Complete!

    When, for example 'Importing...' is showing, and the script then reaches the next bit, 'Transferring...', then the 'Importing...' box should be removed, and 'Transferring...' loaded in its place.


    The idea is, that a user can hit the import button, go and make a cup of tea, come back, and hopefully see 'Complete!' on their screen. Or alternatively, could forgo the tea, and see updates as the process progresses.


    If anyone could point me in the right direction for this, that'd be great... Oh, and also, I don't have the statusbar showing to most users, so if I could avoid using that, that'd be great... Simply updating an existing msgbox, that doesn't pause the script would be great.


    Thanks in advance guys!
    Looking for the perfect beer...

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so create another form, make certain its not modal
    post data to that forms control as required

    eg
    forms!thatform.caption = "hoot de toot"
    forms!thatform!thatcontrol.text = "still doing something"
    forms!thatform.caption = "importing....."
    forms!thatform!thatcontrol1.text = "should be using a progress bar control for this, but I know better"


    when the processing has finished then close that form
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. Create a form (Frm_Status) with the following properties:

    Name: Frm_Status
    DefaultView: Single Form (0)
    AllowFormView: True
    AllowDatasheetView: False
    AllowPivotTableView: False
    AllowPivotChartView: False
    ScrollBars: Neither (0)
    RecordSelectors: False
    NavigationButtons: False
    DividingLines: False
    AutoResize: True
    AutoCenter : True
    PopUp: False
    Modal: False
    BorderStyle: None (0)

    On it, place a label and name it Lbl_Status. Change its format properties as you see fit, in my case:

    Name Lbl_Status
    Visible True
    BackStyle Transparent (0)
    BackColor 16777215
    SpecialEffect Flat (0)
    BorderStyle Solid (1)
    BorderColor 65535
    BorderWidth Hairline (0)
    ForeColor 16711680
    FontName Tahoma
    FontSize 12
    FontWeight Semi-bold (600)
    TextAlign Center (2)

    When the process about which you want to display info begins, open the form Frm_Status:
    Code:
    DoCmd.OpenForm "Frm_Status"
    Forms("frm_status").Lbl_status.Caption = "Initializing"
    Every time you want to change the status message, use:
    Code:
    Forms("frm_status").Lbl_status.Caption = "New Message"
    At the end of the process, use:
    Code:
    DoCmd.Close acForm, "Frm_Status"
    Attached Thumbnails Attached Thumbnails Frm_Status.jpg  
    Have a nice day!

  4. #4
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    A-ha!

    Thanks for the speedy replies you two...

    I started work on a separate form pretty much immediately after posting. I however was having some issues, mainly down to the acReadOnly I decided to implement when opening the form... Not sure why I decided to do that, but live and learn.

    Only slight issue that still remains is that because the main ODBC import starts immediately after I call the form to open, it doesn't get time to load fully and display the first message, all the rest of the code works fine, I just need some way to prep the window, or pause my script for half a second to allow the form to properly load before the thread gets tied up. I'll have a look at hiding the window, and/or setting a timer to delay the ODBC import in a sec.


    I have however left 'Modal' and 'Popup' set to true, and it seems to work all right... Is there a reason you both recommended having these set to false?
    Looking for the perfect beer...

  5. #5
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Hmm...

    Having issues with this one. Everything works fine, except I can't get it to update the custom message box form properly before the bulk of the work begins.

    If I add a 'MsgBox "Blah"' after each of my 'newMessage("Importing...")', and before the actual import code, then it updates fine, but obviously gives a msgbox.

    Without the msgbox's the new form just appears to hang for a minute or two, until it proceeds to the next chunk of code, then everything works fine.

    Is there some way I can force the Form to update? Or can anyone suggest anything to make this problem disappear?

    Thanks again guys...
    Looking for the perfect beer...

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    consider puttign a doevents() after each 'posting' to the other form. this should force the Access runtime to do other things before continuing with the original task in hand
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Cracked it...

    Needed a repaint call to update the screen before the thread gets taken away.

    I assume the MsgBox must call this against every open window in the Access program when it is called...

    Problem solved!


    PS: Why shouldn't I use popup and modal?
    Looking for the perfect beer...

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    modal dialogues seize the focus and don't let other processes within Access regain control untill the modal dialog is finished
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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