excel automation

P

Peter Hafner

Hi there,

I am trying to populate a excel worksheet from a acces query. The code
below works fine. I then tried to limit the output to the curent record
with the query bound to a textbox on the form.
This give a Runtime error: "No given value for one or more required
parameters" at

rsPraxis.Open qryQuery, cnn

When I hardcode the Parameter into the query it works just fine.
Any idea what parameter is missing or what is wron with my code?

Thanks,
Peter


Dim strDatasource As String
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset

rs.Open "qryQuery", cnn

'Create a new workbook in Excel.
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False

Set xlBook = GetObject(Application.CurrentProject.Path & "\Project.xls")
Set xlSheet = xlBook.Sheets("Gauss")
'Transfer the data to Excel.

xlSheet.Range("I3").CopyFromRecordset rs
xlBook.Windows(1).Visible = True

xlBook.Close savechanges:=True

xlApp.Quit

'Close the connection.
rs.Close
cnn.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top