Recordset from a different database

cj-1289

Registered User.
Local time
Today, 21:51
Joined
Jun 12, 2009
Messages
29
I'm trying to open a recordset contained using a different database in VBA6, but said different database just doesn't want to load when I don't use the full path, throwing run-time error 3024, where it can't find the file.

So:
Dim db as Database
Dim db2 as Database
Set db = CurrentDb 'CurrentDb is "MyFirstDatabase.mdb"
Set db2 = OpenDatabase("MySecondDatabase.mdb")

The 3024 is thrown on the second 'Set'.

'MySecondDatabase' is in the same directory as the first, so I shouldn't need the full path.

It DOES all work when I use the full path. But why can't I just use the filename when it's in the same directory?

Thanks in advance.
 
Because Access doesn't assume it is in the same directory. So you have to do it. But you can simplify it if you wish to always assume it is in the same directory:

Set db2 = OpenDatabase(CurrentProject.Path & "\MySecondDatabase.mdb")
 

Users who are viewing this thread

Back
Top Bottom