Hi All
I am writing the following code to pass a recordset in openargs but it displays a message "No Recodset being passed" always.
Any help would be much appreciated.
Code in the report as below:
I am writing the following code to pass a recordset in openargs but it displays a message "No Recodset being passed" always.
Any help would be much appreciated.
Code:
Private Sub btnViewReport_Click()
On Error GoTo Err_btnViewReport_Click
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim stDocName As String
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data source=J:\abs\Pennywell\» Case Trackers\DO NOT USE 2010 test version\2003 Backend Database.mdb;"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "tbldocumentrequest", cn, adOpenKeyset, adLockOptimistic
stDocName = "Detailed Report On RequestP2PID"
DoCmd.OpenReport stDocName, acViewPreview, , , acWindowNormal, rs
Exit_btnViewReport_Click:
Exit Sub
Err_btnViewReport_Click:
If Err.Number = 2501 Then
Else
MsgBox Err.Description
End If
Resume Exit_btnViewReport_Click
End Sub
Code in the report as below:
Code:
Private Sub Report_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then
'msgbox OpenArgs
Else
MsgBox "Not recordset being passed."
Exit Sub
End If
End Sub