M
Manuel
I have a form where the user can set the criteria for a report by selecting
values in certain controls (combo boxes). When the user finishes setting the
criteria/conditions for the report, he/she selects a command button. The
command button builds the SQL string based on the values selected in the
combo boxes, stores the string in a global variable (called ReportSQL_GLOBAL)
and then opens the report.
In the reports On Open event I have a function which calls the value in the
global variable and assigns it to the reports' Record Source property. See
below:
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = GetReportSQL
End Sub
Public Function GetReportSQL()
GetReportSQL = ReportSQL_GLOBAL
End Function
The problem is that each time I run the report I receive an error message
stating: "The record source "SELECT * FROM ...." specified on this form or
report does not exist.
The string being passed is:
SELECT *FROM (tbl_ForeData INNER JOIN tbl_ForeDataME ON tbl_ForeData.LnNum =
tbl_ForeDataME.LnNum) INNER JOIN tbl_SaleDateMonth ON tbl_ForeDataME.LnNum =
tbl_SaleDateMonth.LnNum
This is the basic string returning all records with no slicing of the data
via a WHERE clause, i.e., this is the result of the user not selecting any
report conditions on the form.
The strange thing is that if I paste this exact string in the SQL view of a
query and then run the query I don’t receive the error message; the query
runs fine and return results.
Why am I getting the error message? Is there a limitation on how long the
string can be? I’m taking this same approach when filtering data on another
form (i.e., building a SQL string based on user-selected criteria and then
passing said string to the Forms’ Record Source property) and do not have
this issue.
Any assistance that you all could provide would be greatly appreciated.
Thanks!
Manuel
values in certain controls (combo boxes). When the user finishes setting the
criteria/conditions for the report, he/she selects a command button. The
command button builds the SQL string based on the values selected in the
combo boxes, stores the string in a global variable (called ReportSQL_GLOBAL)
and then opens the report.
In the reports On Open event I have a function which calls the value in the
global variable and assigns it to the reports' Record Source property. See
below:
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = GetReportSQL
End Sub
Public Function GetReportSQL()
GetReportSQL = ReportSQL_GLOBAL
End Function
The problem is that each time I run the report I receive an error message
stating: "The record source "SELECT * FROM ...." specified on this form or
report does not exist.
The string being passed is:
SELECT *FROM (tbl_ForeData INNER JOIN tbl_ForeDataME ON tbl_ForeData.LnNum =
tbl_ForeDataME.LnNum) INNER JOIN tbl_SaleDateMonth ON tbl_ForeDataME.LnNum =
tbl_SaleDateMonth.LnNum
This is the basic string returning all records with no slicing of the data
via a WHERE clause, i.e., this is the result of the user not selecting any
report conditions on the form.
The strange thing is that if I paste this exact string in the SQL view of a
query and then run the query I don’t receive the error message; the query
runs fine and return results.
Why am I getting the error message? Is there a limitation on how long the
string can be? I’m taking this same approach when filtering data on another
form (i.e., building a SQL string based on user-selected criteria and then
passing said string to the Forms’ Record Source property) and do not have
this issue.
Any assistance that you all could provide would be greatly appreciated.
Thanks!
Manuel