jordanking
Programmer
- Sep 8, 2005
- 351
Hello,
I have several forms in an access databse project. I am able to set the recordset value through VBA using an adodb connection to sql server and adodb recordset.
I am running into trouble when trying to do the same with access reports. I found some documentation ( that mentioned previous versions of access, under 2002, you could not do this. But now you can, if you are using a ADP.
the following is the error i get when trying to set the recorset property of a report in the onload event.
the following is the code that I used
the recordset will return a record count and i know it is valid because i used this exact code elsewhere to set the recordset value of a form. The error is not thrown until the sub completes its code.
Does anyone have any ideas as to where this error is comming from or how to set the value of a ADP report to a recordset?
.....
I'd rather be surfing
I have several forms in an access databse project. I am able to set the recordset value through VBA using an adodb connection to sql server and adodb recordset.
I am running into trouble when trying to do the same with access reports. I found some documentation ( that mentioned previous versions of access, under 2002, you could not do this. But now you can, if you are using a ADP.
the following is the error i get when trying to set the recorset property of a report in the onload event.
run-time error '7965'
The object you entered is not a valid recordset property
the following is the code that I used
Code:
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim rsCust As ADODB.Recordset
Set rsCust = New ADODB.Recordset
''''initialise connection string and open connection
cnn.Open Application.CurrentProject.Connection
rsCust.CursorType = adUseClient
Set rsCust = DMS_Customer_Search(cnn, Forms!frmCustomerSearch.Form, Forms!frmCustomerSearch.Form!lstColumn, Forms!frmCustomerSearch.Form!lstSort.Value, Nz(Forms!frmCustomerSearch.Form!intCompanyID.Value, 0), Nz(Forms!frmCustomerSearch.Form!chrFirstName, "NULL"), Nz(Forms!frmCustomerSearch.Form!chrLastName, "NULL"), Nz(Forms!frmCustomerSearch.Form!ChrBilling, "NULL"), Nz(Forms!frmCustomerSearch.Form!intAccountStatus, 0), Nz(Forms!frmCustomerSearch.Form!intSDBID, 0), Nz(Forms!frmCustomerSearch.Form!intERUserID, 0), Nz(Forms!frmCustomerSearch.Form!blnErequest, 2), Nz(Forms!frmCustomerSearch.Form!blnMail, 2), Nz(Forms!frmCustomerSearch.Form!dtCreated, 0))
Debug.Print rsCust.RecordCount
Set Me.Report.Recordset = rsCust
'''release recordset resources
rsCust.Close
Set rsCust = Nothing
cnn.Close
End Sub
the recordset will return a record count and i know it is valid because i used this exact code elsewhere to set the recordset value of a form. The error is not thrown until the sub completes its code.
Does anyone have any ideas as to where this error is comming from or how to set the value of a ADP report to a recordset?
.....
I'd rather be surfing