473,379 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

timer event

Hi All,

This should be simple enough but I'm not getting it working for some
reason so, what's the code and in what events

In AccessXP on a form when a user clicks on a button(btnGetData) I
want a labelbox's text(lblWait) to bold/unbold every second until the
form closes.
The vba behind the btnGetData button gets data and updates a table and
then closes its self. The data it gets and updates could take several
mintues so I want the let the user know something is happening so they
don't think the process is hung and start clicking on stuff or start
pounding on the keyboard.
thanks
bobh.

Apr 26 '07 #1
5 4191
Hi Bob,

Your operation here requires multi threading which requires an object
oriented programmming environment which Access does not support. So it
is not possible to perform this operation within Access. The workaround
would be to create a user control in VB.Net (make it com based) and then
apply that custom user control to your Access application. I had to do
the very same thing for the very same purpose. The code for creating
the user control was a snap in VB.Net (either 2003 or 2005). It was a
label (actually a series of labels) that behaved like a progress meter
except that all it did was grow and shrink and change colors while the
process was underway. I would invoke the control at the beginning of
the procedure in Access (make it visible) and at the end of the
procedure I turn off the user control - make it not visible. The
control is actually constantly running (cpu based) so you just make it
visible = true and visible = false. So the control is independent of
the procedure - of Access - on a totally different thread - it runs
asynchronously to your procedure which is what you want.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 26 '07 #2
On 26 Apr 2007 21:53:13 GMT, Rich P <rp*****@aol.comwrote:

Here is a poor-man's version:
In your code, try to structure things so they happen a chunk at a
time. Then use SysCmd acSysCmdInitMeter and its cousins to use the
built-in progress bar. Something like:
Function MyLongRunningFunction()
dim rs as Recordset
SysCmd acSysCmdInitMeter, "Processing Data", 100
set rs = GetData()
SysCmd acSysCmdUpdateMeter 10
ProcessChunk(1, rs)
SysCmd acSysCmdUpdateMeter 30
ProcessChunk(2, rs)
SysCmd acSysCmdUpdateMeter 50
ProcessChunk(3, rs)
SysCmd acSysCmdUpdateMeter 70
ProcessChunk(4, rs)
SysCmd acSysCmdUpdateMeter 90
FinalProcessing()
SysCmd acSysCmdUpdateMeter 100
rs.Close
SysCmd acSysCmdRemoveMeter
End Function

ProcessChunk would process a fourth of the data passed in.

-Tom.

>Hi Bob,

Your operation here requires multi threading which requires an object
oriented programmming environment which Access does not support. So it
is not possible to perform this operation within Access. The workaround
would be to create a user control in VB.Net (make it com based) and then
apply that custom user control to your Access application. I had to do
the very same thing for the very same purpose. The code for creating
the user control was a snap in VB.Net (either 2003 or 2005). It was a
label (actually a series of labels) that behaved like a progress meter
except that all it did was grow and shrink and change colors while the
process was underway. I would invoke the control at the beginning of
the procedure in Access (make it visible) and at the end of the
procedure I turn off the user control - make it not visible. The
control is actually constantly running (cpu based) so you just make it
visible = true and visible = false. So the control is independent of
the procedure - of Access - on a totally different thread - it runs
asynchronously to your procedure which is what you want.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 27 '07 #3
The only downside with this solution is if the procedure is processing
one long running query - which I believe is the case. Syscmd would only
get called once. I guess if the query could get broken up into chunks,
then yes, syscmd would be an easier workaround. But if the query must
remain intact, then the workaround would be to use the asynchronously
running user control. Believe me, I have been there.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 27 '07 #4
On 27 Apr 2007 01:44:03 GMT, Rich P <rp*****@aol.comwrote:

Agreed. I just thought your "write a dotnet control" was a bit
extreme for the average Access developer. Especially since the
progress bar is really just a convenience. A modal "Please Wait - This
can take a few minutes" dialog and an Hourglass should typically
suffice.

If there is a long-running query, it can sometimes be hacked up into
multiple chunks like this air code:
set rs=db.OpenRecordset("select Min(myPK), Max(myPK) from myTable")
lngMin = rs(0): lngMax = rs(1)
for i = 0 to 9
update sometable .....
where PK_Value between i*(lngMax-lngMin) and (i+1)*(lngMax-lngMin)
SysCmd ...
next i

-Tom.

>The only downside with this solution is if the procedure is processing
one long running query - which I believe is the case. Syscmd would only
get called once. I guess if the query could get broken up into chunks,
then yes, syscmd would be an easier workaround. But if the query must
remain intact, then the workaround would be to use the asynchronously
running user control. Believe me, I have been there.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 27 '07 #5
Actually, the real fix would be -- if a query takes more than a few
seconds to run (or even a few minutes) - then it is time re-evaluate if
the correct tool is being used or if the query needs to be revamped.
More times than not, I have seen queries that could be dramatically
improved by removing unnecessary joins, or in some cases it is just time
to step up to sql server.

As for the .Net solution, yes, a tad overkill. It was one of my first
efforts with .Net back about 5 years ago. Users used to wonder if the
program crashed whenever it took more than a few minutes to run a query.
I just thought I would provide some visual effects. I did something
similar in VB6 before that where I created a simple form exe with a
timer that would do the same thing as the .Net app except that it was a
standalone program that I would call with Shell and then close with API
code. That was asynchronous, but it wasn't really part of the Access
app where the custom user control was part of the application - way more
control.

Going back to breaking up the query goes back to your solution of using
chunks "so to speak" and use syscmd as each portion of the procedure is
processed to display some info in the statusbar.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
7
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: -------------...
10
by: Bob | last post by:
I have a splashscreen running on a thread from Sub Main and it works OK. It displays information in a statusbar about queries. I also have a time on the splashscreen, but the tick event never...
11
by: Philip Wagenaar | last post by:
Hello, I am using a timer object in my Windows Forms Application. Does the code in ..elapsed event run in a diffrent thread? If the interval is set to 10 milliseconds and the time to execute the...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
4
by: Boki | last post by:
Hi All, I have a timer, if my data queue Q has data, the timer should start work, if there is no data in Q, the timer should stop. However, there is an event can fire timer to start. Should I...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.