K
kelly d via AccessMonster.com
In reading, I came across a reply to a post from a Giorgio Rancati for making
a connection to a sql DB be used for a forms record source. in this reply
Giorgio says:
Dim strSql AS String
strSql="Select * From " & _
"[ODBC;DSN=ClientSql;UID=Test;PWD=Test;DATABASE=Sample;].[TableName]"
subfrm.Form.RecordSource = strSql
I tried it. it works great for connecting to an sql DB and making it the
recordsource for a form.
In experimenting, I wanted to see if I could do the same thing with an Access
DB on my machine.
now, I know I can create and save an odbc connection, I can create a query to
connect, or programmatically, I can use OpenDatabase. all work. all have
their uses. but for knowledge purposes (and a couple other reasons I could
explain if anybody cared) I wanted to create a connection string to connect
an .MDB and programmatically assign it to a forms recordsource like the
sample code listed above.
I thought maybe I could just make it simple and grab a access connection
string from connectionstrings.com like:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.
mdb;Uid=Admin;Pwd=;"
and put that inside the brackets but alls I get is either, "Disk or Network
Error" or " you cant use ODBC to import from, export to, or link to an
external MS jet or ISAM DB table" depending on what keywords I tweak.
I cant seem to find the answer so I'm just asking,
Does anybody know what I need to type to make this work. (this, of course
being, me.recordsource="select * from [(fill in the blank)].[(table name];"
thanks.
a connection to a sql DB be used for a forms record source. in this reply
Giorgio says:
Dim strSql AS String
strSql="Select * From " & _
"[ODBC;DSN=ClientSql;UID=Test;PWD=Test;DATABASE=Sample;].[TableName]"
subfrm.Form.RecordSource = strSql
I tried it. it works great for connecting to an sql DB and making it the
recordsource for a form.
In experimenting, I wanted to see if I could do the same thing with an Access
DB on my machine.
now, I know I can create and save an odbc connection, I can create a query to
connect, or programmatically, I can use OpenDatabase. all work. all have
their uses. but for knowledge purposes (and a couple other reasons I could
explain if anybody cared) I wanted to create a connection string to connect
an .MDB and programmatically assign it to a forms recordsource like the
sample code listed above.
I thought maybe I could just make it simple and grab a access connection
string from connectionstrings.com like:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.
mdb;Uid=Admin;Pwd=;"
and put that inside the brackets but alls I get is either, "Disk or Network
Error" or " you cant use ODBC to import from, export to, or link to an
external MS jet or ISAM DB table" depending on what keywords I tweak.
I cant seem to find the answer so I'm just asking,
Does anybody know what I need to type to make this work. (this, of course
being, me.recordsource="select * from [(fill in the blank)].[(table name];"
thanks.