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? :!:

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?

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:

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.

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
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 ;)

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

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.

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.

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

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.

The SQL SELECT dbtask.TaskNum, dbtask was added the the Data1 (CIGARS) bar in the middle. "RecordSource"

I know this is asking to much. Could someone build this and send it to me. I am getting lost in where to put things in. All I wanted to do was have the screen i built refreashed every x number of seconds.

At least something good came out of this. They have agreed to send me to a class to learn basic VB next month.

I would gladly accomplish this task for you, however, I don't have access to SQL. Maybe someone else here does?

Using MS Office 2003 for this right now. Once we get the Network Platform working we will migrate to SQL.


Alright, It's not "pretty" but it does what it's supposed to. You'll need to change the connection string to contain the path to the database, instead of "c:\" as I have it now. Let me know the results, and we can move on to the next phase.


Got it working with a few changes (Path). This is almost like I wanted it. I want to work with it some more. When I pull it up to see if I can show more records on the display. The Gray part where the Timer/Show all Records is at... streaches more and more while the top part opens just a little.

But that is something I want to learn how to fix. There things I want to see is if I can change the Fonts sizes, the Hight & Width of the cells in the Grid.

Thank you for ALL the help. And I hope to start working on the rest of the Application I want to rebuild around this. Taking the MS Outlook forms out of there and create them using VB.

And like I said when we spoke, Any assistance beyond this that you may need, just let me know. You have my e-mail, and I'd be glad to assist you further... I'm looking forward to helping you with the server app. A little tip, it's in the form resize event ;)

Question on this utility. When I run the utility, I set it to poll every 30 seconds. Is the dbbase open all the time this runs or only every 30 seconds when it polls? Also, does it lock the db so nobody can access it during these periods?

Will I started to figure out how to use the Status Monitor and started to make some changes, Font style, Font size, Colmn width and a few other things.

Now I want to get ambitous. The Select statement uses dbtask.group to limit the display to "C". Is there a way that I can change the selections?
"SC", "T", "U', "GT", "LT", "M". To either just one the them or to several selections? Hopefull, with a field that I can change anytime from the utility?

' /* Actually Open the Table With The Aforementioned Criteria */
MyMainRecordset.Open "SELECT dbtask.TaskNum, dbtask.txtstatus, dbtask.Operator1, dbtask.Jobtype, dbtask.Reqby, dbtask.Sjob FROM dbtask WHERE (((dbtask.txtstatus)<>" & Chr(34) & "Finished" & Chr(34) & ") AND ((dbtask.group)=" & Chr(34) & "C" & Chr(34) & "));", MyConnection, adOpenStatic, adLockOptimistic

Once, I get this finished I am starting to work on Forms. Using a menu system, I select a form, "PC Conversion" and it displays a blank form. As a User I fill in all the fields and submit the request. What this will do is take the information and update an MS Access database using a "Job Number" to id each request.

Yeah, Changing The Query shouldn't be a big deal at all. I'm not sure how you want to go about doing it... I would suggest using a bunch of checkbox's and set it up with the checkbox's. In the timer event, search for which checkbox's are checked, and then modify the query string to fit the requested action. If you send me what you've got, I'll help you to modify it into something a little more versatile.

I included a zip of everthing I have. In the jpg I show at the bottom what I want to be to view, either one or several at a time.

BTW, the blank area at the bottom - above the Timer button - how do I get rid of the blank area?

The attachment shows what I am trying to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.