943,945 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jan 19th, 2005
0

Timer Question

Expand Post »
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? :!:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dreyes67 is offline Offline
23 posts
since Jan 2005
Jan 19th, 2005
0

Re: Timer Question

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dreyes67 is offline Offline
23 posts
since Jan 2005
Jan 19th, 2005
0

Re: Timer Question

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:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 20th, 2005
0

Re: Timer Question

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dreyes67 is offline Offline
23 posts
since Jan 2005
Jan 20th, 2005
0

Re: Timer Question

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
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 20th, 2005
0

Re: Timer Question

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mcclth is offline Offline
10 posts
since Nov 2004
Jan 20th, 2005
0

Re: Timer Question

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).
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 23rd, 2005
0

Re: Timer Question

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.
Reputation Points: 16
Solved Threads: 1
Posting Whiz in Training
mnemtsas is offline Offline
200 posts
since Jul 2004
Jan 25th, 2005
0

Re: Timer Question

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.
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	37
Size:	355.3 KB
ID:	866   Click image for larger version

Name:	2.jpg
Views:	22
Size:	163.9 KB
ID:	867  
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dreyes67 is offline Offline
23 posts
since Jan 2005
Jan 25th, 2005
0

Re: Timer Question

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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Can you fix the problem
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: connect to password protected access db





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC