Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using tables/queries from a different .mdb

Status
Not open for further replies.

ormsk

Programmer
Sep 30, 2002
147
GB
I have an application that I want to test with both populated tables and empty tables.

I have created two .mdb’s accordingly. I have created a public module with a sub procedure called SetDB where I was hoping I just ‘comment’ out the db to suit.

The current db is populated.

Public Sub SetDB()
'Set dbs = CurrentDb

Set dbs = DBEngine.Workspaces(0).OpenDatabase("C:\PathName\Empty.mdb")
End Sub

When run, the populated version appears to be selected. How can I set it so that the unpopulated data is used?
 
Try writing a function in the database something like this. You may be opening the Database object but that does NOT mean the data will change. It would be necessary to call the function to return a recordset. You must have some reason not to link the tables right?

Public Function DbInterface() As DAO.Recordset
Dim strSQL
Dim CurDb As DAO.Database
Set CurDb = CodeDb
strSQL = "SELECT ..."
Set DbInterface = CurDb.OpenRecordset(strSQL)
End If

-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top