Reply

Join Date: Jan 2005
Posts: 23
Reputation: dreyes67 is an unknown quantity at this point 
Solved Threads: 0
dreyes67 dreyes67 is offline Offline
Newbie Poster

Timer Question

 
0
  #1
Jan 19th, 2005
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? :!:
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: dreyes67 is an unknown quantity at this point 
Solved Threads: 0
dreyes67 dreyes67 is offline Offline
Newbie Poster

Re: Timer Question

 
0
  #2
Jan 19th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timer Question

 
0
  #3
Jan 19th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: dreyes67 is an unknown quantity at this point 
Solved Threads: 0
dreyes67 dreyes67 is offline Offline
Newbie Poster

Re: Timer Question

 
0
  #4
Jan 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timer Question

 
0
  #5
Jan 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 10
Reputation: mcclth is an unknown quantity at this point 
Solved Threads: 0
mcclth mcclth is offline Offline
Newbie Poster

Re: Timer Question

 
0
  #6
Jan 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timer Question

 
0
  #7
Jan 20th, 2005
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).
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 200
Reputation: mnemtsas is an unknown quantity at this point 
Solved Threads: 1
mnemtsas's Avatar
mnemtsas mnemtsas is offline Offline
Junior Poster

Re: Timer Question

 
0
  #8
Jan 23rd, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 23
Reputation: dreyes67 is an unknown quantity at this point 
Solved Threads: 0
dreyes67 dreyes67 is offline Offline
Newbie Poster

Re: Timer Question

 
0
  #9
Jan 25th, 2005
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
1.jpg   2.jpg  
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timer Question

 
0
  #10
Jan 25th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC