I'm designing some data management software in Access VBA. I'm trying to make it a little more user friendly with the use of a progress bar and forced screen refreshing so the users don't panic and think it has crashed. I've written three global functions (i.e. in a module) to add the access system progress bar, update it and remove it again.
Public Sub progress_init(strMessage As String, intSize As Long)
progressCounter = 0
progressBar = SysCmd(acSysCmdInitMeter, strMessage, intSize)
End Sub
Public Sub progress_increment(Optiona
l intScreenUpdate As Long = 1, Optional intIncrement As Long = 1)
progressCounter = progressCounter + intIncrement
progressBar = SysCmd(acSysCmdUpdateMeter
, progressCounter)
If progressCounter - Round(progressCounter / intScreenUpdate, 0) * intScreenUpdate = 0 Then DoEvents
End Sub
Public Sub progress_kill()
progressBar = SysCmd(acSysCmdRemoveMeter
)
End Sub
and I have 2 global variables in the same module:
' Setup progress bar
Global progressBar As Variant
Global progressCounter As Long
My first question is, am I being really inefficient having globally defined variables which are always in the memory and should I instead have these defined at the form level? Can I improve my design but still retain single definitions of my progress bar functions?
Secondly, for some of the forms it would be nice to have a two tier progress bar for when I have a loop within a loop e.g.
||||||||||||||------------
--- Total Progress
||||||||||||||||||||||||||
||||||----
-- This loop
Is this possible using inbuilt access functions (like the syscommand thing above)? Is this easy to build myself, possibly a progress bar form that I update? How would I control this form using a single global function?
Start Free Trial