S
Steve D
I am trying to open a recordset but I am running into an error because the
query pulls a criteria from a form. The form is open when the code runs but I
still get the error "Missing Parameter" The code is attached below. I am
looking for assistance on passing the parameter to the recordset. Any help is
appreciated
Private Sub Command14_Click()
Dim xlApp As Excel.Application
Dim xlWbk As Excel.Workbook
Dim xlWsht As Excel.Worksheet
Dim acQuery As QueryDef
Dim objRST As Recordset
Dim strQueryName As String
Dim strSheetName As String
strQueryName = "qryAssociates_Paid_Chargeback_Amt"
Set objRST = Application.CurrentDb.OpenRecordset(strQueryName)
strSheetName = Left(strQueryName, 31)
strSheetName = Trim(strSheetName)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWbk = xlApp.Workbooks.Add
Set xlWsht = xlWbk.Sheets(1)
With xlWsht
.Cells.CopyFromRecordset objRST
.Name = strSheetName
End With
Set objRST = Nothing
Set xlWsht = Nothing
Set xlApp = Nothing
Set xlWbk = Nothing
End Sub
query pulls a criteria from a form. The form is open when the code runs but I
still get the error "Missing Parameter" The code is attached below. I am
looking for assistance on passing the parameter to the recordset. Any help is
appreciated
Private Sub Command14_Click()
Dim xlApp As Excel.Application
Dim xlWbk As Excel.Workbook
Dim xlWsht As Excel.Worksheet
Dim acQuery As QueryDef
Dim objRST As Recordset
Dim strQueryName As String
Dim strSheetName As String
strQueryName = "qryAssociates_Paid_Chargeback_Amt"
Set objRST = Application.CurrentDb.OpenRecordset(strQueryName)
strSheetName = Left(strQueryName, 31)
strSheetName = Trim(strSheetName)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWbk = xlApp.Workbooks.Add
Set xlWsht = xlWbk.Sheets(1)
With xlWsht
.Cells.CopyFromRecordset objRST
.Name = strSheetName
End With
Set objRST = Nothing
Set xlWsht = Nothing
Set xlApp = Nothing
Set xlWbk = Nothing
End Sub