RossWindows
Que?
- Local time
- Today, 06:49
- Joined
- Feb 25, 2008
- Messages
- 410
I have the following code on a report.
When the report opens, I would like to set the recordsource to that of the ADODB query, however I am encountering the error: "This feature is not available in an MDB." I understand why the error is appearing, but I also know there has to be a way around it and I've seen examples using DAO, but this is ADODB...
The following is just one variation of the code I have tried and I feel like I've tried almost everything. An help would be greatly appreciated!
When the report opens, I would like to set the recordsource to that of the ADODB query, however I am encountering the error: "This feature is not available in an MDB." I understand why the error is appearing, but I also know there has to be a way around it and I've seen examples using DAO, but this is ADODB...
The following is just one variation of the code I have tried and I feel like I've tried almost everything. An help would be greatly appreciated!
Code:
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
Dim strSql As String
Dim rs As ADODB.Recordset
If Not IsNull(Me.OpenArgs) And Me.OpenArgs <> "" Then
strSql = "exec dbo.spCoachingPrintOut " & _
"@pkCoachingID = N'" & Me.OpenArgs & "'"
Set rs = ExecuteADODBQuery("COACHING", strSql)
Me.RecordSource = Recordset.Open(rs)
Else
DoCmd.Close acReport, Me.Name, acSaveNo
End If
Exit_Report_Open:
Exit Sub
Err_Report_Open:
MsgBox Err.Description
Resume Exit_Report_Open
End Sub