• Display ‘What’s Happening’ Window (VBA for Access2002, Windows Me)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Display ‘What’s Happening’ Window (VBA for Access2002, Windows Me)

    Author
    Topic
    #384560

    I want to create a small information window to tell the user that something (like updating many records in a table) is going on. When that something is finished, this window is to disappear. To do this I have created a small plain form containing only a caption and a label control containing the information message. Switching between Design View and Form View this window looks fine – like a MsgBox with no buttons. However, when I activate it from within my VBA code (DoCmd.OpenForm “frmInfoWindow”, acNormal from the cmdDoSomething_Click button), all I see is the window’s caption and border; the body with its label message is completely transparent showing the windows behind it. Deactivating it (DoCmd.Close acForm, “frmInfoWindow”, acSaveNo) works fine.

    I have left all color properties of the form to Window’s defaults; that is, black text on a gray background. (Detail Section BackColor = -2147483633, lblMessage ForeColor = 0). I have designed many forms over the past few years and this has never happened. How can I see the body of the form?

    Finally, if there is a more sensible way of accomplishing what I’m trying to do, please suggest it.

    Thanks, John

    Viewing 2 reply threads
    Author
    Replies
    • #660169

      You may have to force the window to update itself: something like

      DoCmd.OpenForm “frmPleaseWait”
      Forms!frmPleaseWait.Repaint

      (code from the Form Samples database by Microsoft; replace frmPleaseWait by the name of your form)

      • #660190

        Hans, Your Repaint statement worked beautifully. Any idea why I had to use it?

        Thanks, John

        • #660195

          Opening a form proceeds in several stages – opening the form, loading the data, “painting” the controls. After each stage, Access gives other processes a chance to do something, in this case the instructions following DoCmd.OpenForm. If such a process is time-consuming, drawing the form is postponed. By inserting the Repaint instruction, you force Access to finish displaying the form before proceeding with the next instruction.

    • #660232

      John,

      Have you set this form as pop-up and modal, with a dialog border?

      Sometimes, if I have a form that does not have any bound controls, and I set the properties as above, one of two things happens:

      1 – as you said, the form border appears, but nothing else (as in, you can see thru’ the form), or
      2 – you can see the forms grey background, just the controls are not visible

      To get around this, I use a progress bar control to give a visual indication of progress to the user, along with a form.repaint command – however, this does have a knock on effect for speed, as repainting the form every few moments does slow things down!

      Hope that helps

      • #660312

        Chris, Greetings from the Oregon Pacific coast. Thanks for your ideas. Your mention of a progress bar sounds intriguing. By following the toolbar’s “more controls” link to a humongous list of other controls I discovered the following: 1) Microsoft ProgressBar Control, version 5.0 (sp2), and 2) Microsoft ProgressBar Control, version 6.0. Are you refering to one of these? If so, can you point me to somewhere that will teach me how to use it?

        Thanks again for your help, John

        • #660323

          Hello again John

          Generally I use the progbar v6 – and only in situations where I have an idea of how long the processing should take (i.e. – I know the number of records I’m dealing with).

          In brief:

          Lets say you drop a control on your form and you call it axProgBar

          The progbar has a number of properties that it shares witrh other Access controls (visible, height, length etc) – further to this, it has a number of distinct properties:
          Min = Minimum value of the progbar value range
          Max = Maximum value of the progbar value range
          scrolling = smooth increments, or block style increments
          orientation = horizontal or vertical increments.

          So – say you want to manually import a datafile, whilst also carrying out som,e validations on the data as you go…

          Function Import_Data (strFile as string)

          Open strFile For Input As #1
          ‘Dim statements removed

          recCount = 0
          Do While Not EOF(1)
          Line Input #1, strRec
          recCount = recCount + 1
          Loop
          Close #1

          Me!txtStatus = “Number of Records in Source File Checked!”

          retval = MsgBox(“The process of loading and validating new data can be very lengthy.” _
          & vbCrLf & “Are you sure you wish to continue?”, vbCritical + vbYesNo, “WARNING!”)
          Select Case retval
          Case vbYes
          blRun = True
          Me!btnCancel.Visible = False
          Case vbNo
          blRun = False
          End Select

          If blRun Then
          Set db = CurrentDb
          Set rs = db.OpenRecordset(“tempdatastore”)

          Open strFile For Input As #1
          Me!txtStatus = “Reading and Loading Source File…”
          Me!axProgBar.Max = recCount ‘Set the Progress bar maximum to the number of records to process (min is default 0)
          Me!axProgBar.Visible = True ‘Set the Progress Bar to be visible

          Do While Not EOF(1)
          Line Input #1, strRec
          ‘…VALIDATION CODE HERE
          With rs ‘On valid record, load the entry into the table recordset
          .AddNew
          ‘…ADD RECORD DETAILS HERE
          .Update
          End With
          Next_Record:
          Me!axProgBar.Value = me!axprogBar.Value+1 ‘Increment the Progbar Value
          Me.Repaint ‘Repaint the access form

          Loop
          Close #1
          Me!axProgBar.Visible = False ‘Once all is completed, hide the Progress Bar

          End Function

          This is not perfect code, so be careful if you try to use it – however, it should provide a very simple demonstration of how it can be used to good effect – one other thing – if you do not know how long your code will take to run, then you can set the max value to 10, and just keep looping it back to 0, so it just keeps growing, then going back, and then growing – this way the user can see something is happening, though they are not informed how far from completion something is.

          Okay – enough rambling – I hope that helped!

          • #660708

            Chris, Your explanations and code samples were clear and easy to understand. I got the progress bar up and running in a matter of minutes. Thanks so much for your help. (I got my start in compluters in Bedford in the mid ’60. Good luck in your career.)

            John

    • #660612

      I’ve never had this problem with an Access form (tho’ sometimes when opening pop-up forms with bound combo or listboxes, these controls are slow to be “drawn” or “painted” on screen, to unpleasant effect). However when working in VB Editor, if I minimize VBE main window to work in application window or other program, when VBE main window is restored or maximized, sometimes the last “floating” window to have had focus in VBE is a “see-thru” window, you can see application or desktop window thru it. Also you can not activate the “see-thru” window by clicking title bar, you have to use menu command or keyboard shortcut (such as CTRL+G for Immediate window) to re-activate window & return it to normal, non-transparent state. See attached screen shot for example – the database window is visible thru Project Explorer window. This only occurs with floating windows, not docked windows. Just curious if anyone knows reason for this quirky behavior – it’s more an annoyance than anything else, since you can’t re-activate window directly by clicking it. The OS is WIN 98.

    Viewing 2 reply threads
    Reply To: Reply #660612 in Display ‘What’s Happening’ Window (VBA for Access2002, Windows Me)

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

    Your information:




    Cancel