Hello,
I keep getting the error "Unrecognized database format" when running this code and I can't figure out why.
Any ideas?
Any ideas on how to fix it?
Thank you!
I keep getting the error "Unrecognized database format" when running this code and I can't figure out why.
Any ideas?
Any ideas on how to fix it?
Code:
Sub ImportAgentTablesDAO()
Dim AgentConn As DAO.Database
Dim AgentRec As DAO.Recordset
Dim AgentQry As DAO.QueryDef
Dim DataSource As String
Dim Provider As String
Dim AgentTbl As String
Dim i As Long
DataSource = "G:\U\WCCCTU\TOOLS\Time Off Tracker Backup\Agent Tables.accdb"
AgentTbl = "Agent Info"
Set AgentConn = DBEngine.OpenDatabase(DataSource)
Set AgentQry = AgentConn.QueryDefs("QryAgents")
Set AgentRec = AgentQry.OpenRecordset
ActiveSheet.Range("A1").CopyFromRecordset AgentRec
For i = 1 To AgentRec.Fields.Count
ActiveSheet.Cells(1, i).Value = AgentRec.Fields(i - 1).Name
Next i
End Sub
Thank you!