Full Version: Keeping a text box control live?
UtterAccess Forums > Microsoft® Access > Access Forms
zachattack05
I was wondering if there was a way to keep the data in a text box control live? What I mean is...if I have a switchboard that states something like "total records in table xyz:" and then have a text box control that has a default value that is generated by a small module that checks the number of records in xyz....is it possible to keep it live so that if a record is added it immediately (or on a predictable time frame...say like a minute) changes from 1000 records to 1001 all without the end user doing anything but staring at the monitor?
Doug Steele
You can use the form's Timer.
et the form's TimerInterval property to 60000 (60000 milliseconds, which is 1 minute).
Call the module in the form's Timer event. If your "small module" is a function, you can simply set the form's Timer event to =FunctionName(). If it's a sub, you'll need to use an Event Procedure like:
CODE
Private Sub Form_Timer()
  
  Call SubName
  
End Sub
zachattack05
Thanks! I'll give it a try.
My bad on the wording...it is a /function/ not a module...I'm still working on my first cup of coffee this morning tongue.gif
zachattack05
BTW -
How much of a performance impact does using the timer have if set to a lower number, such as 5000 for every 5 seconds?
zachattack05
Hmmm doesn't seem to be working. Not sure what's going on...It seems like it is running something but the value doesn't update?
Any ideas what I might be missing?
Oset the interval value and the event like you said to. but it doesn't seem to update?
Doug Steele
Okay, what does the function do?
If the function returns the value (as opposed to putting the value into the text box), you'll need
CODE
Private Sub Form_Timer()
  
  Me!NameOfTextbox = FunctionName()
  
End Sub

Either that, or change your function so that it puts the value into the text box.
zachattack05
This is the function:
CODE
Function dbsize()
'Update Completed for Ver. 2.1X on 08/11/09
Dim strBePath As String
Dim sqlBeSizeLookup
Dim rsBeSizeLookup As New ADODB.Recordset
sqlBeSizeLookup = "SELECT * FROM tblGlobalVars WHERE txtName = 'BePath'"
Set rsBeSizeLookup = New ADODB.Recordset
rsBeSizeLookup.CursorType = adOpenStatic
rsBeSizeLookup.Open sqlBeSizeLookup, CurrentProject.Connection
dbsize = (FileLen(rsBeSizeLookup!txtValue) / 1048576)
End Function
zachattack05
Yay that worked!
Thanks! sad.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.