VBA LOOP USING A QUERY & TABLE (1 Viewer)

B&R

Registered User.
Local time
Today, 03:25
Joined
Nov 17, 2003
Messages
19
I have a table set up named PO2. I have a query named UPDATEPOFULLYREC. I would like to get an event written that would go to the first record in the PO2, open up the query (query has criteria set to a form currently and I know will need to change to the table) and run the query based on the information in the first record. The event would then go to the next record in the table and run the query again on that record. It would continue until it has gone through all the records in the table. I plan on triggering this event with a macro. I do not know how to write VBA but I think this is something pretty simple. If any guru is out there, I would appreciate the help. I have attached a sample database. If you can write the VBA, I can test using my database here since the query is directed to a table via odbc.

Thanks so much,
B&R
 

Attachments

  • bill.zip
    7.9 KB · Views: 551

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:25
Joined
Feb 19, 2002
Messages
43,257
No loop is necessary. Queries operate on ALL rows in their domain. Their domain is controlled by criteria. So if the criteria selects 1 row, then 1 row is updated. If the criteria selects 1000 rows, then 1000 rows are updated.

Be careful when you run queries from the code behind a form. Many people do it when they should be using bound forms instead. Tell us more about how the form and query are related.
 

B&R

Registered User.
Local time
Today, 03:25
Joined
Nov 17, 2003
Messages
19
Thanks

You are right! Thanks for taking a look at my problem. A second opinion is always a good idea.

Again Thanks,
B&R
 

Users who are viewing this thread

Top Bottom