Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a macro repeat expression. 1

Status
Not open for further replies.

Musicguy

Technical User
Dec 28, 2000
10
US
In Access 2000 I run a query that returns a different number of records each time. I want to run a macro on those records, but I need an expression that allows the macro to repeat itself only the number of times equal to the number of records returned by the query.

I am running a macro within a macro. The first macro works on the first record. Then it calls the second macro which runs in a loop through the remaining records. How can I make the second macro stop after the last record is modified (obviously, the second macro needs to repeat a number of times equal to the number of records -1.) I see the Repeat Count option, but that is not the answer. It needs to work automatically.

Is this the right approach? Is a proper repeat expression what I need? Thanks.
 
Musicguy,

This is a terrible approach ..... aah!

I suspect you are using the skillset you have and it looks as if you have gone a long way but to achieve this type of processing you need to learn the DAO model.

In DAO VBA code the tasks you describe are elementary.

Going from macros to VBA and DAO is not an easy step but I think it is a necessary one to accomplish the function you describe.

Example code:

Dim rsTable1 as Recordset

Set rsTable1=CurrentDb.Openrecordset("Table1")

Do Until rsTable1.Eof

..... Processing in here

rsTable1.MoveNext
Loop

rsTable1.Close

Set rsTable1 = Nothing

Go with the VBA DAO. I and many others here will help you along the way. :)

Bill Paton
william.paton@ubsw.com

Check out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top