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!

Extracting database values into an MS Word Report???????

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB
Hi,

As a new user to VBA excuse any terms which are wrong. I'm using MS Word 2000 to generate reports via VBA from a MS Access 2000 database.

The problem:
-----------------
I already know how to print preview and generate a report from static values stored within the VBA code.

ie: Sub Fill_Items()

Items(1, 1) = "ACM001"
Items(1, 2) = "ACME CD-ROM"
Items(1, 3) = "1"
Items(1, 4) = "80.00 $"
Items(1, 5) = "80.00 $"

Items(2, 1) = "ACM002"
Items(2, 2) = "ACME FDD"
Items(2, 3) = "1"
Items(2, 4) = "20.00 $"
Items(2, 5) = "20.00 $"

End Sub

But how do I take items from a database instead????
I'm using an ODBC link to a Microsoft Access database. The values that I wish to extract from the database is values stored within columns.

The two columns I wish to extract is one called:
SequenceNo (Integer) and Item (String)


Thanks.. This would be a HUGE help.
Jonathan..
 
something like this (DAO):

Sub msgValues()
Dim openDB As Database
Dim rst As Recordset, i As Integer
On Error Resume Next
Set openDB = OpenDatabase("databasePath\mentes_max.MDB")
Set rst = openDB.OpenRecordset("select * from SaveTable") 'open table in the specified database
rst.movelast
rst.movefirst
While Not rst.EOF
For i = 1 To rst.Fields.Count
MsgBox rst.Fields(i).Value
Next i
rst.MoveNext
Wend
openDB.Close
End Sub

ide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top