Results 1 to 7 of 7

Access VBA - Application.StatusBar?

This is a discussion on Access VBA - Application.StatusBar? within the Microsoft Access forums, part of the Question Forums category; I have some VBA code that takes a while to run and want to display some sort of message giving ...

  1. #1
    Board Regular
    Join Date
    Jun 2002
    Location
    Shanghai, China
    Posts
    144

    Default Access VBA - Application.StatusBar?

    I have some VBA code that takes a while to run and want to display some sort of message giving an indication of progress.
    In Excel VBA I would use simply do something like
    Code:
    Application.StatusBar = "Processing File " & filenamestr
    However Access 2002 doesn't appear to support this. Is there anything simple I can use to display a message that while the program continues running?

    Regards
    HedgePig

  2. #2
    MrExcel MVP Andrew Fergus's Avatar
    Join Date
    Sep 2004
    Location
    New Zealand
    Posts
    5,240

    Default

    Hi

    There is a function to change the status bar text while running VBA code - but it depends on which button / control last had the focus before the code ran. For example, if the user clicked a button called 'cmdRun' then you could add this line of code to the start of the VBA code:

    Me.cmdRun.StatusBarText = "Please wait...."

    HTH, Andrew
    ~ >*()))><(


    I'd rather have a full bottle in front of me than a full frontal lobotomy.

  3. #3
    MrExcel MVP
    Moderator
    SydneyGeek's Avatar
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    12,203

    Default

    I came across a Status routine that I use in my apps.
    Code:
    Sub Status(pstrStatus As String)
        
        Dim lvarStatus As Variant
        
        If pstrStatus = "" Then
            lvarStatus = SysCmd(acSysCmdClearStatus)
        Else
            lvarStatus = SysCmd(acSysCmdSetStatus, pstrStatus)
        End If
        
    End Sub
    To use, you could have Status("Processing Record " & lngRecNo)

    at the end, use Status("") to clear the status bar.

    Denis
    Self-preservation: For when you've got yourself in a jam
    ------------------------------------------------------
    My site contains a number of Excel and Access Resources

  4. #4
    Board Regular
    Join Date
    Jun 2002
    Location
    Shanghai, China
    Posts
    144

    Default

    Ha! That's exactly what I wanted SydneyGeek. Many thanks.

    HedgePig

    P.S. Andrew, thanks for the reply but i'm not using any buttons, so I'll stick with Sg's suggestions.

  5. #5
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Default Re: Access VBA - Application.StatusBar?

    I have this function (it is a function, as I believe you can only call functions from macros) that is to update the status bar that I run between steps of a macro. However, it isn't working. During the running of the macro, I only see my last status bar after the macro has finished running.

    Function StatusBar(Optional varQuery As Variant)
    Dim Stat As Variant
    If Not IsMissing(varQuery) Then
    If varQuery <> "" Then
    Stat = SysCmd(acSysCmdSetStatus, "Query Running: " & varQuery)
    Else
    Stat = SysCmd(acSysCmdClearStatus)
    End If
    Else
    Stat = SysCmd(acSysCmdClearStatus)
    End If
    End Function

    My only idea is that I set Echo and SetWarnings to NO at beginning of macro and set them to YES at end. But I sent them to yes *after* my last status bar update, and that status bar message still displays.

    After looking, I now wonder why I don't use the ECHO function, since it seems to have a "Status Bar Text" field.

    Docē

  6. #6
    MrExcel MVP
    Moderator
    SydneyGeek's Avatar
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    12,203

    Default Re: Access VBA - Application.StatusBar?

    If you are using macros rather than VBA, Echo is a viable option.
    See... Echo Macro Action - Access - Office.com

    Denis
    Self-preservation: For when you've got yourself in a jam
    ------------------------------------------------------
    My site contains a number of Excel and Access Resources

  7. #7
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Default Re: Access VBA - Application.StatusBar?

    That actually didn't work. I suspect it is because my macro is running queries, so each step has the "Running Query" status bar (on the right hand side of screen). I'm assuming that takes precedence over my status bar function. Any idea if that is true? And if it is, how to split the status bar? I did notice when I use my function, the status bar does have a | in the center of it, so it looks split.

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com