I am wondering if there is a way to connect to a particular table within a database. Right now I have a vb program that connects to an access database that has one table in it, but I would like to connect it to a different database that has about 10 tables. Is there a way to specify the particular table you want the vb program to link to?
Would it sort of look like this?
Set db = ws.OpenDatabase(App.Path & "\database.mdb")
Set rs = db.OpenRecordset("Table", dbOpenTable)
I don't know esactly what do you refer. If you connect to a database, using the RecordSource property you can SELECT * FROM thetableyouneed to use, or selecting a couple of them at the same time if you need.
I am trying to connect a visual basic program to an access database. It already works with the existing database, but I want to use a different database. What I am wondering is if the code I gave above will connect to a table in a database.
The reason I am asking this is because as I mentioned, it already works with an existing database, but when I export the table the program uses in the existing database, import it into the new database, change the name on the database that I want to connect to, I get an error saying the either the database or the table is not there, which is incorrect because they are there.
The 2 databases are in the same folder, so they paths are the same. I can't think another reason why this isn't working.
well .. I don't know If its possible to set two connections at once in the same queary, and maybe this is not an ellegant soluttion, but you can try to put two ADOs instead one and connect each of them to a different database, then make a bucle for comparing the values you are getting
Are you looking for a query that will span two databases. For this, you should use the Jet OLEDB provider. Then you can create one query to bring back data between multiple Jet databases, between Access and Excel, etc...since all use the same data provider.
Basically something like this:
'just as an example insert into this database from antother
strInsert = "INSERT INTO mytable SELECT * FROM [MS Access;DATABASE=C:\Testing.mdb].[Clients]"
'execute into THIS active connection
"Artificial Intelligence is no match for natural stupidity." ~unknown