P
Phoenix
Hi,
running this code i keep running into this error.
Here is the code (part of it):
strSQL = "SELECT * FROM qrydeelnemersnaarexcel WHERE
tblActiviteiten.act_project = '201040' AND tblDeelnemers.dn_actief = Yes;"
Set d = CurrentDb
Set rs = d.OpenRecordset(strSQL, dbOpenDynaset)
intMaxCol = rs.Fields.Count
If rs.RecordCount > 0 Then
MsgBox ("GEEN RECORDS AANWEZIG!")
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
Set objXL = New Excel.Application
With objXL
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
For iCols = 0 To rs.Fields.Count - 1
.Cells(1, iCols + 1).Value = rs.Fields(iCols).Name
Next
.Range(.Cells(1, 1), .Cells(1, rs.Fields.Count)).Font.Bold =
True
With objSht
.Range("A2", .Cells(intMaxRow, intMaxCol)).CopyFromRecordset
rs
.Columns.AutoFit
.Columns.AutoFilter
End With
End With
objWkb.SaveAs ("F:\Administratie 2003\deelnemers\" & ProjectFileNaam
& ".xls")
objXL.Quit
End If
I tried a lot to get rid of it (if i keep the WHERE part out of strSQL then
it runs but i need to select a projectnumber (201040))
Also tried DAO and ADO but same result.
Pls help me?
Txs in advance, Michael
running this code i keep running into this error.
Here is the code (part of it):
strSQL = "SELECT * FROM qrydeelnemersnaarexcel WHERE
tblActiviteiten.act_project = '201040' AND tblDeelnemers.dn_actief = Yes;"
Set d = CurrentDb
Set rs = d.OpenRecordset(strSQL, dbOpenDynaset)
intMaxCol = rs.Fields.Count
If rs.RecordCount > 0 Then
MsgBox ("GEEN RECORDS AANWEZIG!")
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
Set objXL = New Excel.Application
With objXL
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
For iCols = 0 To rs.Fields.Count - 1
.Cells(1, iCols + 1).Value = rs.Fields(iCols).Name
Next
.Range(.Cells(1, 1), .Cells(1, rs.Fields.Count)).Font.Bold =
True
With objSht
.Range("A2", .Cells(intMaxRow, intMaxCol)).CopyFromRecordset
rs
.Columns.AutoFit
.Columns.AutoFilter
End With
End With
objWkb.SaveAs ("F:\Administratie 2003\deelnemers\" & ProjectFileNaam
& ".xls")
objXL.Quit
End If
I tried a lot to get rid of it (if i keep the WHERE part out of strSQL then
it runs but i need to select a projectnumber (201040))
Also tried DAO and ADO but same result.
Pls help me?
Txs in advance, Michael