Private Sub Command1_Click()
Dim db_file As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & _
"\"
db_file = db_file & "books.mdb"
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
' Open the Recordset.
Set rs = conn.Execute("SELECT * FROM Books", , _
adCmdText)
' Connect the Recordset to the DataReport.
Set rptBooks.DataSource = rs
rptBooks.WindowState = vbMaximized
rptBooks.Show vbModal
rs.Close
conn.Close
End Sub
|