msgbox delay

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jollywg
    New Member
    • Mar 2008
    • 158

    msgbox delay

    Right now i have the user press a button and a file is imported via vba. I would like a message box to pop up and tell the user to "Please Wait". How do i cause this "delay" until the import is complete?

    Thanks for any advice!
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    I don't think you can do this with a messagebox; you'll have to "roll your own."

    Create a small form, making it look like a messagebox. Make it PopUp, set Border Style to either Dialog or None, strip all the native controls (divider line, nav buttons, Close Button, etc.) then use code like this in your button:

    Code:
    Private Sub ImportFile_Click()
      DoCmd.OpenForm "YourPopUpFormName"
      'Code here to import file
      DoEvents
      DoCmd.Close acForm, "YourPopUpFormName"
    End Sub
    The DoEvents line should keep the form closing command from executing until the file has finished importing.

    What kind of files are you importing that take enough time to import that it's noticable?

    Linq ;0)>

    Comment

    • Jollywg
      New Member
      • Mar 2008
      • 158

      #3
      What kind of files are you importing that take enough time to import that it's noticable?

      Linq ;0)>[/QUOTE]


      just one xls file about 13mb, it takes about 4 or 5 seconds to load. I just dont want the user clicking the button 1000 times. Could i use the doevents cmd in the load event method.

      Code:
      Private Sub cmdSalesLookup_Click()
      msgBox "Please Wait"
      Doevents
          DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "MasterZip", "C:\MasterZip.xls", True
      this may not be the exact code, but something similar to this?

      Thanks!
      Matt

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        No. As I said in my original post, if you want the "Please wait..." message to disappear on its own, when the form is finished being imported, you cannot use a messagebox! A messagebox can only be closed by the user clicking on its appropriate button. In order to do what you want, you'll have to create a small form, following the instructions I gave you, to mimic a messagebox.

        To be honest, though, if all you're talking about is 4-5 seconds for this file to import, a messagebox is all I'd fool around with. It will tell them what's going on, and by the time they read your message and click the OK button, the file will probably be through loading. It would be a different story if you were talking about 30-60 seconds or longer.

        Linq ;0)>

        Comment

        • Jollywg
          New Member
          • Mar 2008
          • 158

          #5
          Originally posted by missinglinq
          I don't think you can do this with a messagebox; you'll have to "roll your own."

          Create a small form, making it look like a messagebox. Make it PopUp, set Border Style to either Dialog or None, strip all the native controls (divider line, nav buttons, Close Button, etc.) then use code like this in your button:

          Code:
          Private Sub ImportFile_Click()
            DoCmd.OpenForm "YourPopUpFormName"
            'Code here to import file
            DoEvents
            DoCmd.Close acForm, "YourPopUpFormName"
          End Sub
          The DoEvents line should keep the form closing command from executing until the file has finished importing.

          What kind of files are you importing that take enough time to import that it's noticable?

          Linq ;0)>

          How do you strip off the close min, max buttons and the record navigator in 2003?

          Comment

          • fcb98292
            New Member
            • Oct 2008
            • 1

            #6
            Originally posted by Jollywg
            How do you strip off the close min, max buttons and the record navigator in 2003?
            In the properties box for any form, there are yes/no and other choices for each of the form's properties, including those you named. Be sure to click the "All" tab to see all choices. Success.

            Comment

            Working...