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

Advance Recordset and Trigger a Function...?

Status
Not open for further replies.
Oct 13, 2004
39
US
hi all -

I have a form with a lot of records in it ( > 150)

on this form is a button which generates a word document report based on the info in the form

I need to create a macro/function that will trigger the report generation function advance the form recordset and repeat until it gets to the end.
(in word i have a document_open event which will send the report to the printer spool and close doc)

I think this is a simple thing to do but i dont know enough VBA to acomplish this recordset advance, and call function... probably on somekind of loop or something?

Any help is greatly appreciated in advance!!!!!!!!!!!!!!!!!!1

Cheers-
 
A do...loop function is what you are after... embedded in that will be DoCmd.GoToRecord to advanced to the next record on teh form. I would recommend using the Access code to initialize the print function as well, otherwise you may run problems if Access is opening multiple documents before Word can send the job to the spooler and close the document. By embedding these within your loop function, you can be sure that only one Word instance is open at a time


"Only the educated are free.
 
thanks xiong - but i need to print the word document so I fugured that was no longer in the scope of the access code since it is an entirely different application.

Can you please elaborate on your recomendation?

Thankss!
 
Take a look at the Recordset, Bookmark, MoveFirst, MoveNext and EOF methods/properties of the Form/DAO.Recordset objects.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I think what cliffhanger means is the scope of the access code is lost when exporting to word and printing.

I'm not sure if that's a true statement, but what is a true that I know is you can open the Word document as an object, do whatever you want, then loop to the next record.

Randall Vollen
National City Bank Corp.
 
that is correct randall - I am generatign a word report that i eventually need to print - i dont think you can trigger printing a word document from access but i could be wrong - the biggest issue i am having right now is finding a mechanism to loop through the recordset

my knowledge of VBA is very VERY rusty and I have never dealt with automated advancement of recordsets in a form

any code advice would be more then appreciated!!!!!!!!!

THANKS
 
It'll take me a bit to dig up, but it is possible to call the printing funtion from Access to Word (or any other of the MS Suite). I try and find an application I did a few years ago that should still work.


"Only the educated are free.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top