evilbungle
New member
- Local time
- Today, 08:39
- Joined
- May 25, 2012
- Messages
- 5
Hi, I have another problem with an Access 07 database I am building to write reports in Excel.
I have several queries that I paste into Excel and for some reason one of them is giving me different results when it pastes than when I run the query from the Access Window.
Through Access the Query "qry_QuotingDownload_agb" returns 11 Records but when I run the following code as part of my sub:
It only returns 9 records (It is the top 9 records the query resturns in the database window)
Any help would be appreciated.
Thanks
Adam
I have several queries that I paste into Excel and for some reason one of them is giving me different results when it pastes than when I run the query from the Access Window.
Through Access the Query "qry_QuotingDownload_agb" returns 11 Records but when I run the following code as part of my sub:
Code:
Private Sub cmdrun_Click()
Dim qdefOne As QueryDef
Dim rsOne As Recordset
Dim iCols As Integer
Dim param As Variant
Dim param2 As Variant
'Quoting
Set qdefOne = CurrentDb.QueryDefs("qry_QuotingDownload_agb")
For Each param In qdefOne.Parameters
param.Value = Eval(param.Name)
Next param
Set rsOne = qdefOne.OpenRecordset
xlSheet.Range("X1").Select
For iCols = 0 To rsOne.Fields.Count - 1
xlSheet.Cells(1, iCols + 24).Value = rsOne.Fields(iCols).Name
Next
xlSheet.Range("X2").CopyFromRecordset rsOne
rsOne.Close
Set rsOne = Nothing
Set qdefOne = Nothing
It only returns 9 records (It is the top 9 records the query resturns in the database window)
Any help would be appreciated.
Thanks
Adam