Connection to Database

andm

New member
Local time
Today, 13:04
Joined
Feb 1, 2001
Messages
6
Hi there!

I am just trying to connect to a table in my Access database. I want to do it from a module that is in that database.

My goal is write SQL queries and work with the a recordset within the modules. But I have to figure out how to connect to the tables first!

Can you help me? Thanks!!
 
To connect to the active database tables:

dim dbs as database
dim rst as recordset
dim Sql_Str as String

set dbs = CurrentDb
set rst = dbs.OpenRecordset("TableName")

This is a very simple way to open a table. You can get specific by using a SQL String.

set dbs = CurrentDb
Sql_Str = "Select ThisField, ThatField FROM TableName Where BirthDate < #1/1/00#"
set rst = dbs.OpenRecordset(SQL_Str)

HTH
 

Users who are viewing this thread

Back
Top Bottom