Hi all,
I'm having a problem with some SQL code in VB I'm using for Access. I have a combo that allows a user to select an employee and opens a query to display its results. Yesterday, this code seemed to work fine and give the proper results. There have been no changes to this code since yesterday.
Trying to update the combo box now gives the following error :
""The specified field <Emp_ID> could refer to more than one table listed in the FROM clause of your SQL statement. (Error 3079)""
I realize that it could refer to more than one table... that's what I would like.
Clicking the help button on the error tells me to add the .<field> to the table, making the code like this: (the spacing may be off, but the syntax is correct.)
This produces an error saying that "C:/...MyDocuments/tblD10.mdb" could not be found. The help on this doesn't give much info.
Anyone know what might cause the inital code to stop working?
Any insight appreciated,
Thanks in advance.
I'm having a problem with some SQL code in VB I'm using for Access. I have a combo that allows a user to select an employee and opens a query to display its results. Yesterday, this code seemed to work fine and give the proper results. There have been no changes to this code since yesterday.
Code:
Private Sub cboEmpName_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Dim qdf As QueryDef
Dim strSql As String
Set db = CurrentDb()
strSql = "SELECT * FROM tblD10, tblD11, tblD12, tblD13, " & _
"tblD14, tblD15, tblD21, tblD24, tblD25, tblD26, tblD29, " & _
"tblD30, tblD31, tblD86, tblD90 " & _
"WHERE Emp_ID = " & cboEmpName & ";"
Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)
With db
Set qdf = .CreateQueryDef("tmpEmpSearch", strSql)
DoCmd.OpenQuery "tmpEmpSearch"
.QueryDefs.Delete "tmpEmpSearch"
End With
db.Close
qdf.Close
End Sub
""The specified field <Emp_ID> could refer to more than one table listed in the FROM clause of your SQL statement. (Error 3079)""
I realize that it could refer to more than one table... that's what I would like.
Clicking the help button on the error tells me to add the .<field> to the table, making the code like this: (the spacing may be off, but the syntax is correct.)
Code:
Set db = CurrentDb()
strSql = "SELECT * FROM tblD10.Emp_ID, tblD11.Emp_ID, " & _
"tblD12.Emp_ID, tblD13.Emp_ID, tblD14.Emp_ID, tblD15.Emp_ID, " & _
"tblD21.Emp_ID, tblD24.Emp_ID, tblD25.Emp_ID, tblD26.Emp_ID, " & _
"tblD29.Emp_ID, tblD30Emp_ID, tblD31Emp_ID, tblD86Emp_ID, tblD90Emp_ID " & _
"WHERE "tblD10.Emp_ID, tblD11.Emp_ID, " & _
"tblD12.Emp_ID, tblD13.Emp_ID, tblD14.Emp_ID, tblD15.Emp_ID, " & _
"tblD21.Emp_ID, tblD24.Emp_ID, tblD25.Emp_ID, tblD26.Emp_ID, " & _
"tblD29.Emp_ID, tblD30.Emp_ID, tblD31.Emp_ID, tblD86.Emp_ID, tblD90.Emp_ID = " & cboEmpName & ";"
Anyone know what might cause the inital code to stop working?
Any insight appreciated,
Thanks in advance.
Comment