| | |
Timer Question
![]() |
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
I am a new user to VB so forgive any simple questions.
I just created a tool that will display the Job Number, Requested by, Status, Group, Operator.
As this database has about 50-75 requests added to it daily and with luck we process them all or 90% of them each day. This utility I wrote will be centered on the Status of a request.
I want to see if I can add a Timer so the screen is updated/refreshed every x seconds. I want to let each user of this to enter how many seconds to wait before the screen is refreshed.
Anybody have any Ideas? :!:
I just created a tool that will display the Job Number, Requested by, Status, Group, Operator.
As this database has about 50-75 requests added to it daily and with luck we process them all or 90% of them each day. This utility I wrote will be centered on the Status of a request.
I want to see if I can add a Timer so the screen is updated/refreshed every x seconds. I want to let each user of this to enter how many seconds to wait before the screen is refreshed.
Anybody have any Ideas? :!:
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
Need to word this different:
I created a form using DBGrid where I used SQL to filter it.
SELECT dbtask.TaskNum, dbtask.txtstatus, dbtask.Operator1, dbtask.Jobtype, dbtask.Reqby, dbtask.Sjob, dbtask.group FROM dbtask WHERE (((dbtask.txtstatus)<>"Finished") AND ((dbtask.group)="C"));
When we get a new request the status is Submit, thus it will display in the above grid. When a request form is finished the status (txtStatus) is changed to Finished and it will not display in the grid.
Right now, I start the project to view the current status and kill it. A few min. later I restart it to view the currrent status. Is there a way that I can refresh the dbgrid every few seconds?
I created a form using DBGrid where I used SQL to filter it.
SELECT dbtask.TaskNum, dbtask.txtstatus, dbtask.Operator1, dbtask.Jobtype, dbtask.Reqby, dbtask.Sjob, dbtask.group FROM dbtask WHERE (((dbtask.txtstatus)<>"Finished") AND ((dbtask.group)="C"));
When we get a new request the status is Submit, thus it will display in the above grid. When a request form is finished the status (txtStatus) is changed to Finished and it will not display in the grid.
Right now, I start the project to view the current status and kill it. A few min. later I restart it to view the currrent status. Is there a way that I can refresh the dbgrid every few seconds?
Yeah, Don't close the program.... use a timer control .... you can even use a form to set the "refresh rate" of the timer control. have a box on the form (a textbox) and a button on the form (set rate) and make it in seconds.... then in the code for the set rate button, do a:
Obviously Rename Timer1 to whatever you name it, and rename text1 to whatever you name the textbox.... that will set the interval (you are multiplying by 1000 because the timer control works in milliseconds...not seconds. Also, Keep in mind that you can not exceed 60000 (1 minute, 60 seconds) with the timer control's duration.
In the timer control... you would do something to refresh the grid... I'm guessing it's going to be a bit of a payload, but if it only happens now and again, say, 15 or 20 seconds... maybe even less, the toll won't be too deadly. Anyway, I'd suggest, in the timer control to REDO your code. An Example would be to erase everything in the grid control, and redo your computations. Then perhaps use the .refresh method, and it should update just fine.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
timer1.interval = val(text1.text) * 1000
Obviously Rename Timer1 to whatever you name it, and rename text1 to whatever you name the textbox.... that will set the interval (you are multiplying by 1000 because the timer control works in milliseconds...not seconds. Also, Keep in mind that you can not exceed 60000 (1 minute, 60 seconds) with the timer control's duration.
In the timer control... you would do something to refresh the grid... I'm guessing it's going to be a bit of a payload, but if it only happens now and again, say, 15 or 20 seconds... maybe even less, the toll won't be too deadly. Anyway, I'd suggest, in the timer control to REDO your code. An Example would be to erase everything in the grid control, and redo your computations. Then perhaps use the .refresh method, and it should update just fine.
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
1. Created Textbox -
2. created command button
3. Rename textbox - Rate
4. Rename commaand button - clock
5. added timer from tool box - renamed digital
6. digital - properties
Interval = 5000
7. added code - clock
Private Sub clock_Click()
Clock.Interval = Val(Rate.Text) * 5000
DBGrid1.Refresh
End Sub
Error - Method a data member not found
When I enter a number (5) in the textbox and press the button.
It highlights .Interval
2. created command button
3. Rename textbox - Rate
4. Rename commaand button - clock
5. added timer from tool box - renamed digital
6. digital - properties
Interval = 5000
7. added code - clock
Private Sub clock_Click()
Clock.Interval = Val(Rate.Text) * 5000
DBGrid1.Refresh
End Sub
Error - Method a data member not found
When I enter a number (5) in the textbox and press the button.
It highlights .Interval
I'm pretty sure the problem is this:
VB has an internal command, called "Rate", I don't remember if it is a function or a class (that requires you to make an instance of it)... but if you rename the textbox from Rate to ... say, tmpRate, or CurrentRate, or something of that nature... it may solve the problem.
I also would only times the interval by 1000, but, it's your code
VB has an internal command, called "Rate", I don't remember if it is a function or a class (that requires you to make an instance of it)... but if you rename the textbox from Rate to ... say, tmpRate, or CurrentRate, or something of that nature... it may solve the problem.
I also would only times the interval by 1000, but, it's your code
•
•
Join Date: Nov 2004
Posts: 10
Reputation:
Solved Threads: 0
sorry if this sounds harsh, it's not - from what I can tell, this isn't at all what you need your program to do. Right now, from the code in your last message, what happens is you click on the command button (clock), attempt to set the interval property of a nonexistent object (hence you ".Interval" error: your timer was named "digital" not "Clock", and refresh your grid only when the button is pressed, not when your clock increments.
What I would do is this:
1) create text box "Rate"
2) create command button "Clock"
3) create timer "digital"
4) Specify in the Properties of digital itself, not the code, the interval should be 5000 (if you want 5 seconds)
5) Initialize digital as disabled (property "enabled" set to "false")
6) Make the code in Clock_Click() simply set digital.Enabled = True
Any questions or if I don't seem to have anderstood your programs aims, just say so here or mcclth@gmail.com
What I would do is this:
1) create text box "Rate"
2) create command button "Clock"
3) create timer "digital"
4) Specify in the Properties of digital itself, not the code, the interval should be 5000 (if you want 5 seconds)
5) Initialize digital as disabled (property "enabled" set to "false")
6) Make the code in Clock_Click() simply set digital.Enabled = True
Any questions or if I don't seem to have anderstood your programs aims, just say so here or mcclth@gmail.com
I think the goal is to be able to CHANGE the value of the timer control, to whatever is in the textbox.... so, if the textbox says "10" they want it to be 10 seconds before the timer event fires. You're 100% correct (which I missed) about Clock and digital... good catch. Rate, Still, is a VB command, and objects should not be named the same as internal commands. Because then you would have to explicitely call it with the entire path (formname.rate.text).
Perhaps try adopting a decent naming protocol. So a text box name will start with 'txt', a check box with 'chk', a label with 'label'. It prevents this sort of stuff from happening as well as making your code a lot easier to understand and quicker to program.
Mark Nemtsas
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
Still not able to get what I am looking for. I attached a couple if Jpgs to show what I want. In the dbGrid picture it shows the number of Jobs request that have been submitted using MS Outlook to create the forms. When the form is mailed to our Control Rm. the data is upgrade to the Access database.
That is where the scroll view would show us the number of jobs that are NOT = to Finished in the Status field.
That is where the scroll view would show us the number of jobs that are NOT = to Finished in the Status field.
I'm not seeing the code in your timer.... more to the point, I'm not seeing a timer. The solution, as I see it.... is placing your code
I think it is.... in your timer event. Basically, Redo The Task, Every Time The Timer Event Fires. You might have to clear the grid first... and then re-put everything back on it. So, Every time the timer fires it's event.... the grid gets cleared.... and then re-populated with whatever it is you are trying to put in there.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SELECT dbtask.TaskNum, dbtask.txtstatus, dbtask.Operator1, dbtask.Jobtype, dbtask.Reqby, dbtask.Sjob, dbtask.group FROM dbtask WHERE (((dbtask.txtstatus)<>"Finished") AND ((dbtask.group)="C"));
I think it is.... in your timer event. Basically, Redo The Task, Every Time The Timer Event Fires. You might have to clear the grid first... and then re-put everything back on it. So, Every time the timer fires it's event.... the grid gets cleared.... and then re-populated with whatever it is you are trying to put in there.
![]() |
Similar Threads
- Timer question: Scoreboard (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Can you fix the problem
- Next Thread: connect to password protected access db
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






