Importing mdb database into user form

M

Mdmax

Hi,
I have a user form that creates an msword report, it connects to an
access2000 database called Docs.mdb, the 7 fields within the "Docs"
table are: Last, Name, Credential, Number, Building, City, State, zip.

The code works perfectly in the user form and brings up all the
relevant fields, but when I click the OK button, only the "last name"
of the doctor appears on my report (and all the other fields are left
out, for some reason).

The code I am using is within the: Private Sub
UserForm_Initialize()/end sub statement

(enabled library is: “Microsoft DAO 3.6 Object Library”)

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
'Open the database to retrieve data
Set db = OpenDatabase("C:\Databases\Docs.mdb")
'Define the first recordset
Set rs = db.OpenRecordset("SELECT * FROM Docs ORDER BY [Last]")
'Determine the number of records in the recordset
With rs
MoveLast
NoOfRecords = .RecordCount
MoveFirst
End With
'Set the number of ListBox columns = number of fields in the recordset
ComboBoxDocs.ColumnCount = rs.Fields.Count
'Load the ListBox with the retrieved records
ComboBoxDocs.Column = rs.GetRows(NoOfRecords)
'Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

How can I get the final report (an msword.doc, with a bookmark
"alldocs", for the combobox entry text), to display all the rest of the
other (above) fields, and not just the last name?...

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top