Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting error 2501 on DoCmd.Openquery --

Status
Not open for further replies.

ToyFox

Programmer
Jan 24, 2009
161
US
I have this function that runs a series of queries then runs a function that takes the end result and dumps it into an EXCEL template....

This routine works fine for me, but testing it on someone else's pc renders error 2501 on the the step3 query....
Why would this happen....Can someone shed some light here.


Function ReportBuild()
Dim strFileName As String
Dim Mo
Dim Dy

DoCmd.SetWarnings False
DoCmd.OpenQuery "AccountsWithLE"
DoCmd.OpenQuery "KYC_Remediation_Step1"
DoCmd.OpenQuery "KYC_Remediation_Step2"
DoCmd.OpenQuery "KYC_Remediation_Step3" **** This is where the error occurred

DoCmd.OpenQuery "KYC_Remediation_Step4"
DoCmd.OpenQuery "AML_Remediation_Report"
DoCmd.OpenQuery "AML Remediation Report Final"

'Call AML_Reports
Call RunAML_Report_With_Requirement_Type
DoCmd.SetWarnings True

strFileName = "G:\Business Compliance Group\Project\"

If Len(Day(Date)) = 1 Then
Dy = "0" & CStr(Day(Date))
Else
Dy = CStr(Day(Date))
End If

If Len(Month(Date)) = 1 Then
Mo = "0" & CStr(Month(Date))
Else
Mo = CStr(Month(Date))
End If


' A,B,C,D Report
strFileName = "G:\Business Group\Remediation Project\"
strFileName = strFileName & Mo & Dy & "-Remediation Report With Gradings.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "AML Remediation Status Report (Weekly)", strFileName, , , True
 
error 2501 is a cancel error code. I dont see any problem with the code above ... was a cancel button clicked while testing?? if so you could trap the error

HTH << MaZeWorX >> Remember amateurs built the ark - professionals built the Titanic [flush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top