r/visualbasic • u/m0nkeyofdeath • Jul 19 '22
Stuck on a problem with MS Access table when running an SQL query in VB6. "The Specified field could refer to more than one table listed in the FROM clause of your SQL statement."
I'm not very familiar with VB6 but I am troubleshooting something that is supposed to create a report in Christal reports and get this message evetime I try to run it. it doesn't crash just creates an error window with:
"Failed to retrieve data from the database. The Specified field 'EmpID' could refer to more than one table listed in the FROM clause of your SQL statement."
This is the code that I'm using.
frmReportViewer.sReport = "PayrollEmployee.rpt"
frmReportViewer.sFilter = "SELECT Payroll.*, Employees.* FROM Payroll INNER JOIN Employees ON " & _
"Payroll.EmpID=Employees.EmpID " & sSQL & " ORDER BY Payroll.EmpName, Payroll.FromDate"
frmReportViewer.sFilterText = sText
frmReportViewer.Caption = "RCL Software - Payroll Report - By Employee"
When I leave the employee number field blank the report runs and creates a report with the grid and layout that was designed but its blank. When an employee number is put in the field the report is not generated and creates the error dialog window.
Any help is greatly appreciated.




