This is a bit of a combination of two previous threads of mine - referenceing three different databases in a single SQL query and an unrecognized database format.
VB6 using ADO hitting/creating Access databases
MDB1- already exists, primary source of data
MDB2- already exists and has tables of lookup values (in Access 2000)
MDB3- newly created by the program as follows
Set catMDB = New ADOX.Catalog
With catMDB
.Create "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source="C:\MDB3.mdb"
End With
Set catMDB = Nothing
I open a connection to MDB1 as follows:
Set cnInventory = New ADODB.Connection
With cnInventory
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MDB1
End With
I am building a long SQL string to do the following (greatly simplified and using words; I hope it comes across correctly)
SELECT several fields from several tables in MDB1 and a couple fields from two tables in MDB2
INTO PointAnalysisTable IN MDB3
FROM that includes 4 inner joins on tables in MDB1 plus
LEFT JOIN "[C:\Codes].Pollutant" AS poll ON field in table in MDB1=poll.field
INNER JOIN "[C:\Codes].Units" AS unt ON field in table in MDB1=unt.field
The code works great if MDB1 is an Access 2000 or later. But if MDB1 is Access97, then I get the error "Unrecognized database format" for C:\Codes.
I tried adding provider information, for example "Provider=microsoft.jet.oledb.4.0;[C:\Codes].units" but then I got a syntax error in the FROM statement.
In another thread, zemp suggested using ODBC connections and DSN, but I am not familiar with that, and I would have to program the software to do it through code.
Is there a way to have the program open an Access 2000 or Access 97 database opened with Jet 4.0 and not crash?
Thanks, Jim
VB6 using ADO hitting/creating Access databases
MDB1- already exists, primary source of data
MDB2- already exists and has tables of lookup values (in Access 2000)
MDB3- newly created by the program as follows
Set catMDB = New ADOX.Catalog
With catMDB
.Create "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source="C:\MDB3.mdb"
End With
Set catMDB = Nothing
I open a connection to MDB1 as follows:
Set cnInventory = New ADODB.Connection
With cnInventory
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MDB1
End With
I am building a long SQL string to do the following (greatly simplified and using words; I hope it comes across correctly)
SELECT several fields from several tables in MDB1 and a couple fields from two tables in MDB2
INTO PointAnalysisTable IN MDB3
FROM that includes 4 inner joins on tables in MDB1 plus
LEFT JOIN "[C:\Codes].Pollutant" AS poll ON field in table in MDB1=poll.field
INNER JOIN "[C:\Codes].Units" AS unt ON field in table in MDB1=unt.field
The code works great if MDB1 is an Access 2000 or later. But if MDB1 is Access97, then I get the error "Unrecognized database format" for C:\Codes.
I tried adding provider information, for example "Provider=microsoft.jet.oledb.4.0;[C:\Codes].units" but then I got a syntax error in the FROM statement.
In another thread, zemp suggested using ODBC connections and DSN, but I am not familiar with that, and I would have to program the software to do it through code.
Is there a way to have the program open an Access 2000 or Access 97 database opened with Jet 4.0 and not crash?
Thanks, Jim