C
choli0090
Hello everyone,
I am trying to figure out what I am missing to give the excel output the name
based upon the criteria at the time during the loop. This is what I have.
qryGroup - The list of Id's that are used for the criteria for the main query.
I have ftnRepID as the criteria under the RepId field (one of the fields part
of the query)
qryMain - The Main query
tblData - Table containing the data.
I also have 2 modules:
modFunctions
Function ftnRepID
On Error Resume Next
ftnRepId = vRepId
End Function
The other module..
Sub RepOutput
set db = Current Db
set recset = db.openRecordSet ("qryMain")
DoCmd.SetWarnings False
recset.MoveFirst
Do Until recset.EOF
vRepId = recset!RepCode
DoCmd.transferSpreadsheet acExport, acSpreadSheetTypeExcel9, "C:\Folder" &
vRepId & ".xls"
recset.MoveNext
Loop
Recset.close
DoCmd.SetWarnings = True
Debug.print "Done"
However when I run this, I get a run time 2522 error on the
transferSpreadsheet part. Overall I am trying to have the file name be the
repId that its processing at the time.
Any help would much be appreciated..
Thanks
I am trying to figure out what I am missing to give the excel output the name
based upon the criteria at the time during the loop. This is what I have.
qryGroup - The list of Id's that are used for the criteria for the main query.
I have ftnRepID as the criteria under the RepId field (one of the fields part
of the query)
qryMain - The Main query
tblData - Table containing the data.
I also have 2 modules:
modFunctions
Function ftnRepID
On Error Resume Next
ftnRepId = vRepId
End Function
The other module..
Sub RepOutput
set db = Current Db
set recset = db.openRecordSet ("qryMain")
DoCmd.SetWarnings False
recset.MoveFirst
Do Until recset.EOF
vRepId = recset!RepCode
DoCmd.transferSpreadsheet acExport, acSpreadSheetTypeExcel9, "C:\Folder" &
vRepId & ".xls"
recset.MoveNext
Loop
Recset.close
DoCmd.SetWarnings = True
Debug.print "Done"
However when I run this, I get a run time 2522 error on the
transferSpreadsheet part. Overall I am trying to have the file name be the
repId that its processing at the time.
Any help would much be appreciated..
Thanks