Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: "Toast" popups in Access & Progress bars

    2 questions:

    1) Is there is a way to display "Toast" popups in access... Example: Outlook - when you recieve an e-mail a little non-intruisve popup in the bottom right of your screen appears. It doesn't steal focus from the user but sends them a useful notification.

    2) Is there a way to create a progress messagebox in access... Example: When you're installing software it informs the user of how many percent the process is complete as it is happening.

    Any suggestions/aswers would be greatly appreciated.
    If you experts don't know the answer then I think we have a lovely new thing to develop!

    - GeorgeV
    George
    Home | Blog

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    1) Modeless dialog with a timer ... Invoke with the message to display ...

    2) You can try to mimic a progressbar but, there is no meaningful way to determine the actual progress that something is completing by (how much of the print job HAS been sent to the printer, how much of the file has copied from 1 directory to another) in Access that I know of ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    To answer your second question. I don't remember exactly how it works, but here's the gist of it.

    Put a Global variable in a class module SinMeterWidth as Single

    Create a pop up form with a long rectangular label, and an overlapping
    rectangle with a starting width of 0 and a different backcolor. Mine also has a label with a "Generating..." text.

    In the forms Load event

    Code:
    Private Sub Form_Load()
      SinMeterWd = Me.ctlProgMeter.Width
    End Sub
    Put another sub in a public module that updates the form. Basically, what it does is:
    1) adjust the width of the rectangle (progress bar)
    2) recalculate the percent complete and display
    3) show the product it is currently calculating

    sinPos is just how far along it is in the recordset

    I'd elaborate farther, but I have to run to a meeting.

    Code:
    Function Progress(StrPlan, Optional strProduct, Optional sinPos)
      'update the progress meter form
      Dim dblProgress As Double, strPostFix As String
      If SinMeterWd = 0 Then
        SinMeterWd = Forms!ZMGENPLANSTATUS!.ctlProgMeter.Width
      End If
      If IsMissing(sinPos) Then
        Forms!ZMGENPLANSTATUS!ctlProgMeter.Visible = False
        Forms!ZMGENPLANSTATUS!recProgMeter.Visible = False
        Forms!ZMGENPLANSTATUS!lblPlan.Caption = StrPlan
      ElseIf StrPlan = "Orders" Then
        dblProgress = SinMeterWd * sinPos
        Forms!ZMGENPLANSTATUS!recProgMeter.Width = dblProgress
        Forms!ZMGENPLANSTATUS!ctlProgMeter.Caption = CInt(sinPos * 1000) / 10 & "%"
        Forms!ZMGENPLANSTATUS!lblPlan.Caption = "Updating Orders - " & strProduct
      Else
        dblProgress = SinMeterWd * sinPos
        Forms!ZMGENPLANSTATUS!recProgMeter.Width = dblProgress
        Forms!ZMGENPLANSTATUS!ctlProgMeter.Caption = CInt(sinPos * 1000) / 10 & "%"
        Forms!ZMGENPLANSTATUS!lblPlan.Caption = "Generating " & StrPlan & " Plan - " & strProduct
      End If
      Forms!ZMGENPLANSTATUS.Repaint
      DoEvents
    End Function
    Inspiration Through Fermentation

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by M Owen
    1) Modeless dialog with a timer ... Invoke with the message to display ...
    Could you explain what you mean here? I'm not sure how to even start this one

    At RNG - I will have a play about with your idea of changing the widtch of a textbox - very clever. I have a long process (takes around 30 seconds) that I wanted to add this to - I think I will increment it in steps or add a common dialog..
    Step 1 - Processing xxx
    Step 1 - Complete
    that might be a simpler way in this siituation, but your answer is oh so very clever!
    Cheers for that - will look into it all a bit more tomorrow - must dash off to play a game of football! (soccer )

    GeorgeV
    George
    Home | Blog

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by georgev
    Could you explain what you mean here? I'm not sure how to even start this one

    At RNG - I will have a play about with your idea of changing the widtch of a textbox - very clever. I have a long process (takes around 30 seconds) that I wanted to add this to - I think I will increment it in steps or add a common dialog..
    Step 1 - Processing xxx
    Step 1 - Complete
    that might be a simpler way in this siituation, but your answer is oh so very clever!
    Cheers for that - will look into it all a bit more tomorrow - must dash off to play a game of football! (soccer )

    GeorgeV
    Sorry ... Mixing my VB and VBA metaphors ... Make a form that's modeless (Not Modal). Add a timer for auto shutdown ... Call/invoke the form with a parameter which is your message to display (the open event will work here) ... You could even pass in a display location ... You could resize the form depending on the length of the text message ... What is there to not understand?
    Back to Access ... ADO is not the way to go for speed ...

  6. #6
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    For #2 you can also use Microsoft's progress bar control. Open a new form, goto Insert/ActiveX Control and then search the list for Microsoft ProgressBar Control. Then just use the controls Properties to change the look.

    I agree, you can't show an accurate estimate for how long things will take, but at least the user knows something is still happening.

    I created a Class Module that pops up a form with two text boxes and a progress bar. Here is the code if you are interested (note:you will have to create your own form with the textboxes and progress bar):

    Code:
    Option Compare Database
    Option Explicit
    
        Dim strFormName As String
        Dim intMeterType As Integer
    
        Public Enum ProgressMeterType
        
            appTwoLineProgressMeter = 1
            appOneLineProgressMeter = 2
            
        End Enum
    
    Public Sub NewMeter(Optional intMeterType As ProgressMeterType)
    
        Select Case intMeterType
        
            Case appOneLineProgressMeter
                
                strFormName = "frmUtilityCOMPAProgressMeterSmall"
                
            Case appTwoLineProgressMeter
            
                strFormName = "frmUtilityCOMPAProgressMeterMedium"
                
            Case Else
            
                strFormName = "frmUtilityCOMPAProgressMeterOneLineSmall"
            
        End Select
        
        DoCmd.OpenForm strFormName
    
    End Sub
    
    Public Property Get Title1() As Variant
    
        Title1 = Forms(strFormName).Controls("txtTitle1").Value
        
    End Property
    
    Public Property Let Title1(ByVal vNewValue As Variant)
    
        Forms(strFormName).Controls("txtTitle1").Value = CStr(vNewValue)
        Forms(strFormName).Repaint
        DoEvents
        
    End Property
    
    Public Property Get Caption() As Variant
    
        Caption = Forms(strFormName).Caption
        
    End Property
    
    Public Property Let Caption(ByVal vNewValue As Variant)
    
        Forms(strFormName).Caption = CStr(vNewValue)
        Forms(strFormName).Repaint
        DoEvents
        
    End Property
    
    Public Property Get Progress() As Variant
    
        Progress = Forms(strFormName).Controls("ocxProgressMeter").Value
        
    End Property
    
    Public Property Let Progress(ByVal vNewValue As Variant)
    
        'Do not allow the value to exceed 100
        If vNewValue > 100 Then vNewValue = 100
        
        Forms(strFormName).Controls("ocxProgressMeter").Value = CInt(vNewValue)
        Forms(strFormName).Repaint
        DoEvents
        
    End Property
    
    Public Property Get Message1() As Variant
    
        Message1 = Forms(strFormName).Controls("txtMessage1").Value
        
    End Property
    
    Public Property Let Message1(ByVal vNewValue As Variant)
    
        Forms(strFormName).Controls("txtMessage1").Value = CStr(vNewValue)
        Forms(strFormName).Repaint
        DoEvents
        
    End Property
    
    Public Property Get Title2() As Variant
    
        If intMeterType <> appOneLineProgressMeter Then
    
            Title2 = Forms(strFormName).Controls("txtTitle2").Value
            
        End If
        
    End Property
    
    Public Property Let Title2(ByVal vNewValue As Variant)
    
        If intMeterType <> appOneLineProgressMeter Then
    
            Forms(strFormName).Controls("txtTitle2").Value = CStr(vNewValue)
            Forms(strFormName).Repaint
            DoEvents
        
        End If
        
    End Property
    
    Public Property Get Message2() As Variant
    
        If intMeterType <> appOneLineProgressMeter Then
        
            Message2 = Forms(strFormName).Controls("txtMessage2").Value
        
        End If
        
    End Property
    
    Public Property Let Message2(ByVal vNewValue As Variant)
        
        If intMeterType <> appOneLineProgressMeter Then
        
            Forms(strFormName).Controls("txtMessage2").Value = CStr(vNewValue)
            Forms(strFormName).Repaint
            DoEvents
        
        End If
        
    End Property
    
    Public Sub CloseMeter()
    
        DoCmd.Close acForm, strFormName, acSaveNo
        
    End Sub
    With this, I can put the form and the Class Module in my code database and call it from any database that references my code database. It gives a consistent look/feel.

    Here is an examaple of its use:

    Code:
        Dim clsProgressMeter As ProgressMeter
        
        PushCallStack "SubdivideData"
        
        If gbooHandleErrors Then On Error GoTo ErrorHandler
        
        strSQL = "SELECT ProgramID, GroupID FROM tblDataStandard GROUP BY ProgramID,GroupID"
        
        rstPrograms.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
        
        With rstPrograms
        
            While Not .EOF
            
                'Set up the progress meter to used during the subdividing
                Set clsProgressMeter = GetNewProgressMeter()
                clsProgressMeter.NewMeter appOneLineProgressMeter
                clsProgressMeter.Title1 = "Subdividing ProgramID " & !ProgramID & " and GroupID " & !GroupID & "..."
                clsProgressMeter.Message1 = ""
                clsProgressMeter.Caption = "Subdividing Batch"
                clsProgressMeter.Progress = 0
                
                SubdivideProgramID !ProgramID, !GroupID, clsProgressMeter
                .MoveNext
                
            Wend
            
            .Close
            
        End With
            
        'Remove the progress meter
        clsProgressMeter.CloseMeter
        
        'Cleanup
        Set rstPrograms = Nothing

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ok, I've built myself a little custom progress bar (as a seperate form) by setting a textbox width property when certain events occur...

    I just have one problem and I have tried every event I can think of:

    How can I make my code run after the form has displayed?

    I've added an example mdb of what i'm doing... Currently the code runs when the command button is pressed. I want it to run when the form is displayed.

    Hopefully I'm just being a moron and it's somethign really easy

    Cheers peeps
    Attached Files Attached Files
    George
    Home | Blog

  8. #8
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would use OnCurrent as long as you don't plan on cycling through records. OnCurrent occurs when everything else is done (form displayed, data queried, etc.) and Access has displayed the first record. Assuming this form is not bound to data, then you won't have to worry about moving to another record and restarting the progress bar.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hmm, my progrress bar (and newly developed toast popup) are separate forms from the one performing the processing...
    What to do, what to do...
    George
    Home | Blog

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I think I'm probably being to clever, but I have made it so my toast popup "slides" into view from behind the taskbar - before sliding away again...

    The problem then is that as soon as I click off the toast and give focus to another form - the loop processing I have used (docmd.movesize?) is then applied to whatever form has focus - meaning it dissapears off screen as well...

    Is there any way I can make the transformations form specific, regardlesss of what form has focus?
    Code:
    Private Sub Command6_Click()
    Dim InitialX As Integer
    Dim InitialY As Integer
    Dim tWidth As Integer
    Dim i As Integer
    
    tWidth = Me.Form.Width
    
    'GetX and GetY return the screens resolution dimensions
        InitialX = (GetX * 15) - tWidth
        InitialY = (GetY * 15)
            
        i = 0
        
        Do While i < (tWidth / 10)
            DoCmd.MoveSize InitialX, InitialY, tWidth, tWidth
            InitialY = InitialY - 10
            i = i + 1
            'Pause stops the program for the specified time (InSeconds)
            Pause (0.01)
        Loop
        
        Pause (5)
        i = 0
        
        Do While i < (tWidth / 10)
            DoCmd.MoveSize InitialX, InitialY, tWidth, tWidth
            InitialY = InitialY + 10
            i = i + 1
            Pause (0.01)
        Loop
        
        DoCmd.Close
        
    End Sub
    George
    Home | Blog

  11. #11
    Join Date
    May 2005
    Posts
    1,191
    Don't know if this helps, but I've used this website before.
    Me.Geek = True

  12. #12
    Join Date
    May 2016
    Posts
    1
    Sorry for bumping this thread but I was looking for a solution for this, but ended up creating my own.

    Check it out. I developed the solution based on Google Material guideline.

    https://github.com/AzriAhmad/MakeAToast/

    Direct link
    https://github.com/AzriAhmad/MakeATo...ases/tag/0.0.1
    Last edited by azria; 05-27-16 at 17:55. Reason: Direct release link

Posting Permissions

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