Retrieving Records from another database

S

Steven

I want to view the records in another(ie. history)
database.

I am doing something like this currently out of my main
database.

Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim rst As DAO.Recordset
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("PathAndFileName", False,
False, "MS Access;PWD=" & VARPassword)
Set rst = db.OpenRecordset("TableName", dbOpenDynaset)

----Problem is here---

I can edit change update delete.....with the record set in
the other(ie history) database...but I cant figure how
to "SELECT" the records to view in a query.
How is this done? Thank you for your help.

Steven
 
J

Jay Vinton

...but I cant figure how
to "SELECT" the records to view in a query.

Hi Steven,

If your table is named "Customers" and you want to get all columns, then

..OpenRecordset("Customers") is the same as a SQL query, such as
..OpenRecordset("Select * from Customers")

If you want to limit the number of columns returned, use

..OpenRecordset("Select FirstName, LastName From Customers")

If you want to limit the number of rows returned, use

..OpenRecordset("Select * From Customers Where City = 'New York' ")

A good book for learning SQL is
http://www.amazon.com/exec/obidos/tg/detail/-/0201447878/102-9117917-3990550?v=glance

Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top