DrJavaJoe...you seem to be the VB Guru. Maybe you can help me one more time trying to print a DataReport of the Records that are returned when I run the From/To date search code you've helped me with.
I've added the code below to a cmdPrint Button that's on the Form with the txtBoxes and grdList DataGrid. I'm trying to print the search results onto a DataReport named "RentRoll2."
Private Sub cmdPrint_Click(Index As Integer)
OpenReport1
End Sub
Private Sub OpenReport1()
Dim rpt As RentRoll2
Set rpt = New RentRoll2
rpt.Display Me.grdList.rs, vbModal
Set rpt = Nothing
End Sub
After the grdList is filled with the Records, if I click the cmdPrint Button to print out the DataReport, I get this compile error: Method or data member not found.
The code for populating the grdList with the Records between the user entered dates is shown below and is working fine (Thanks to you!)
Option Explicit
Dim Cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Dim rs_searchResult As New ADODB.Recordset
Private Sub cmdSearch_Click(Index As Integer)
'Reopen recordset with filtered data
Call FindData
'cmdPrint.Enabled = True
End Sub
Private Sub Form_Load()
If IsDate(txtDateFrom.Text) And IsDate(txtDateTo.Text) Then
'Now Get all the records from the database
Call FindData
End If
End Sub
Private Sub GetConnection()
If Cn.State = 0 Then
Dim ConnectionString As String
'Database should be in the Application's Path
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\EHicks\RESIDENTIAL PROPERTY MANAGER\RPM.mdb;Persist Security Info=False"
'First Open the Connection before Using it in Recordset
Cn.CursorLocation = adUseClient
Cn.Open ConnectionString
End If
End Sub
'This sub is used to open a recordset with data that matched the search criteria
'and then shows that to a datagrid named "grdList"
Private Sub FindData()
Dim SQLString As String
'Use the Search Criteria in the Query
SQLString = "SELECT * FROM SortRentDeposits WHERE DepDate BETWEEN #" & txtDateFrom.Text & "# AND #" & txtDateTo.Text & "# ORDER BY DepDate"
'Close the recordset if it is already open
If rs.State = 1 Then
rs.Close
End If
'Now Open Recordset again with SQLString
Call GetConnection
rs.Open SQLString, Cn, adOpenStatic, adLockOptimistic
'Bind Recordset with Grid
Set grdList.DataSource = rs
End Sub
Again, can I impose on you for any suggestions?
Thanks in advance!