View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Using access data to fill-in pre-printed report forms

There are various ways of doing this. For one, see the article "Access a
database and insert into a Word document the data that you find there" at:

http://www.word.mvps.org/FAQs/InterD...DataFromDB.htm

The following procedure in the Initialize event of a UserForm in Word can be
used to load a list box on that form with the records from a table in Access
so that the user can select the record that they want and then have the data
from that record inserted into the document that is created when a new
document is created based on the template in which the userform is located.

Private Sub UserForm_Initialize()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("D:\Access\ResidencesXP.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM Owners")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"S.Hanagan" wrote in message
news
Aside from using the cumbersome mail merge, is there a decent way to take
access data and use it to fill-in a printable form? By "form" I mean like
a
tax return, not an access "form."