G
Guest
Hi there.
I have a button on a form which I would like to export the data on this
form's sub form into excel. When I try this:
Private Sub Command42_Click()
Dim db As Database
Dim rstQueryData As Recordset
Dim objExcel As Object, intRowCounter As Integer
Set db = CurrentDb
Set objExcel = CreateObject("excel.Application")
With objExcel
.Visible = True
.Workbooks.Add
Set rstQueryData = db.OpenRecordset("qryTest")
intRowCounter = 0
Do Until rstQueryData.EOF
.Range("A2").offset(intRowCounter, 0) = rstQueryData![Vendor]
.Range("b2").offset(intRowCounter, 0) = rstQueryData![InvTotal]
intRowCounter = intRowCounter + 1
rstQueryData.MoveNext
Loop
End With
End Sub
This works beautifully until I add the following parameter to my qryTest in
my InvAmt field:
I then get err 3061 too few parameters expected 1. Do I have to repeat the
parameter in the query in code or what do I do?
Thanks for all help offered!
J
I have a button on a form which I would like to export the data on this
form's sub form into excel. When I try this:
Private Sub Command42_Click()
Dim db As Database
Dim rstQueryData As Recordset
Dim objExcel As Object, intRowCounter As Integer
Set db = CurrentDb
Set objExcel = CreateObject("excel.Application")
With objExcel
.Visible = True
.Workbooks.Add
Set rstQueryData = db.OpenRecordset("qryTest")
intRowCounter = 0
Do Until rstQueryData.EOF
.Range("A2").offset(intRowCounter, 0) = rstQueryData![Vendor]
.Range("b2").offset(intRowCounter, 0) = rstQueryData![InvTotal]
intRowCounter = intRowCounter + 1
rstQueryData.MoveNext
Loop
End With
End Sub
This works beautifully until I add the following parameter to my qryTest in
my InvAmt field:
[forms]![frmLookup]![Amt]
I then get err 3061 too few parameters expected 1. Do I have to repeat the
parameter in the query in code or what do I do?
Thanks for all help offered!
J