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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through the records on a form 2

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
CA
Hi Folks

What I need to do is to open a form using a command button, then loop through the records on form till EOF, here are the steps :

1) click on a button to open the form ( which is on an
utility form )
2) Start with the first recrod on the form
3) Do some stuff like create PDF report and mail it ( for
which I already have the code - thanks to the forum )
The code generates PDF report based on the data on the
form for each record and email it to the address on the
form.
4) Then move to the next record and do the same stuff again
for the data in the next record

Loop until the last record and do the stuff

5) when done, display a msg saying job done.


Can someone please write me the VBA code.

Thanks very much for your time.

Rgds
Brenda
 
Why do you need to move the record pointer with Visual Basic? Does your form have navigation buttons? If not, why can't you use them? I'll give you some code if you really want to move the record pointer with Visual Basic, but first I want to make sure that's really what you want to do. What is the purpose of displaying data on this Form? The other day you said that you were only using the Form to create and mail PDF reports. Unless the user has some interaction with the application to cause this to happen, I don't understand the purpose of the Form. If you wanted the user to be able to select a specific record to create a PDF report for, I would understand why you are using a Form. In this case, the user might search for or navigate to the record that they want to mail, and would press a command button to execute the code. If you are simply doing this for all records in the table, the user doesn't have to do anything other than say "Go", and for that you don't need a form. If you help me understand what you are trying to accomplish, I could better help you.

dz
dzaccess@yahoo.com
 
Hi dz, As I mentioned earlier my report depends on an id field on the form, unless I get to move the records on the form, the above code doesn't work for for me as it produces only one customers report as many times as it loops with just different names.
Thanks
Brenda
 
I copied the following Set statement from one of your posts on another thread.

Set rs = db.OpenRecordset("qu_registrars", dbOpenDynaset, dbReadOnly)

Is qu_registrars the same Query that we are talking about on this thread? If so, are the fields invoice_no and ext_id in qu_registrars? What is the name of the field on the form that contains the ID, and where does it get its data? Is the field not named ext_id?

dz
dzaccess@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top