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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run query in currrent DB

Status
Not open for further replies.

PapaSmurf

IS-IT--Management
May 16, 2001
48
GB
I know how to make connections to databases, but how to I get a connection to the current DB? Essentially I want to run a query from the press of a button, then do some other stuff (mail something to email address that come out of the query).

Any help/ code snips much appreciated!
 
Is the query a saved one within the current access database?

Next question: Is it an action query (one that inserts/updates/deletes) or a Select query that retrieves data?
If the former, look at QueryDefs; if the latter look at Recordset objects for executing within code.

John
 
Yes, the query has already been designed and present in the current database. The query will return a list of email address, so yes I need to use a recordset to acquire this data.

What I'm still not sure about is the connection string that refers to the current database?

Ben
 
The connection string is only used if it is necessary to connect to a remote database, whether it is a client/server system such as SQL server, or an external Access database file, so you shouldn't need it.

John
 
Ok. Believe me I've tried.

Can you give me some hint as to what my code should look like?

Set rst = New ADODB.Recordset
rst.Open "SELECT * from UserProcaccess"

Doesn't seem to work.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top