Access queries and SQL Server views. - TechRepublic
General discussion
August 21, 2001 at 03:41 AM

Access queries and SQL Server views.

Hi guys,

I’m trying to run a couple of Access SQL queries with the DoCmd.RunSQL command. Here is a simplified version of my code:

“Private Sub Report_Open(Cancel As Integer)
Dim db As Database

Set db = CurrentDb
DoCmd.RunSQL “DELETE * FROM tblLocalCompanies”
AddRunSQL
Set db = Nothing
End Sub

Private Sub AddRunSQL()
Dim db As Database

Set db = CurrentDb

DoCmd.RunSQL “SELECT ID, NAICCN, COMPANY, SuperFleet_Code, ” & _
“SuperFleet_Apex, FLEET_CODE, Fleet_Apex, MEMBER_TYPE, CO_ID ” & _
“INTO tblLocalCompanies” & _
“FROM vw_CompaniesOnly”

Set db = Nothing

End Sub”

The problem is the second RunSQL statement. I’m trying to put a recordset, selected from a SQL view (vw_CompaniesOnly), into a local table in an .mdb file. The .mdb operates with linked tables and views to a SQL Server backend. When I try to create the recordset from the linked view “vw_CompaniesOnly” and dump it in a local table “tblLocalCompanies”, the compiler gives me the following error “Run-time error ‘3067’: Query input must contain at least one table or query.”

Anyone who had run into a similar problem?

Regards. Boris.

This discussion is locked

All Comments