• Howto: PopUp Form (Access 97/SR1)

    Author
    Topic
    #357754

    I have a piece of code that prints a set of reports, some of the reports are opened from Excel then printed. I am looking for a way to put a ‘PopUp’ form on the screen during the time that the code is executing.

    I created a small form to use as the popup form and named it frmWait. How do i go about coding in the load/show of the form, the call of the other sub (P22 is the other subs name), then the unload of the form.

    Here is what I have tried, but I get a variable not defined error. Upon clicking the ‘debug’ button the frmWait.Show gets highlited.

    Function p22a()
        frmWait.Show
        'Call P22
        Unload frmWait
    End Function
    

    What am I doing wrong. BTW, this is my first time attempting to open a form through code (does it show) shrug question

    Viewing 1 reply thread
    Author
    Replies
    • #532137

      You may want to try:

      DoCmd.OpenForm "frmWait", acNormal
      'Your Code Here
      DoCmd.Close acForm, "frmWait", acSaveNo

      HTH thumbup

    • #532173

      Are you using VB or Access as the front end? The code you posted is VB code, and Mark’s answer is Access VBA code.

      If it’s VB, the Show method should work to both load and show the form but I believe you need the vbModal or vbModeless argument to make it work.

      • #532185

        I am using Access. Have not had a chance to try Mark’s suggestion. Will get to it tomorrow.

        • #532338

          I inserted mark’s code and tried the macro. The form comes up and the goes away like it should, however, all you see is an outline of the form. The middle of the form is all white. I have attached what the form looks like when running (bad_pic) and what the form should look like (good_pic) (I don’t know if there is a way to upload two images, so I edited the previous post and attached the good_pic). Any ideas on what I am doing wrong.

          • #532356

            Try a Me.Repaint in the form’s open event.

            • #532362

              Edited by Charlotte to eliminate horizontal scrolling

              Charlotte, that didn’t work. However, it triggered an obscure thought (very rare that this happens). What if I try to refresh the ‘PopUp’ form from in the middle of my other code. This did work.

              I listed below what I was trying to do, and highlited in red the line that I added.

              Sub P22()
                  Dim XLApp As New Excel.Application
                  'Start printing the Update sheet for the Production Assistants
                  DoCmd.RepaintObject acForm, "frmWait"
                  XLApp.Workbooks.Open  _
                    "Srvnt01SprodmgrShendersFilesProd_AstAttendance2001SUP#022.XLS"
                  XLApp.Sheets("Update").Range("E3").Value = "07/01/01"
                  XLApp.Sheets("Update").PrintOut
                  XLApp.ActiveWorkbook.Saved = True
                  XLApp.ActiveWorkbook.Close
                  XLApp.Quit
                  Set XLApp = Nothing
              End Sub
              Function p22a()
                  DoCmd.OpenForm "frmWait", acNormal
                  Call P22
                  DoCmd.Close acForm, "frmWait", acSaveNo
              End Function
              

              Thanks again for the quick response and the triggering of my gray matter. salute

            • #532381

              As long as you got it working, that’s the important thing. smile

    Viewing 1 reply thread
    Reply To: Howto: PopUp Form (Access 97/SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: