LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Querying Data from Secured Access Database with VBA

I have two solutions that work. One uses the DAO and the other the ADO
library.

The DAO solution is (from the Access.Security Newsgroup):

Dim DaoDBEngine As Object '(All others are string declarations)

Set DaoDBEngine = CreateObject("DAO.DBEngine.36")
DaoDBEngine.SystemDB = strDBWorkgroupPathName
DaoDBEngine.DefaultUser = strDatabaseUserID
DaoDBEngine.DefaultPassword = strDatabasePassword

Set CurrentDB = DaoDBEngine.OpenDatabase(strDatabasePathName)

The ADO solution is a combination of Tom's and Jamie's input, and previous
code I used to connect to a secured Oracle database. It is:

Dim Cnn As New ADODB.Connection '(All others are string declarations)

strProviderName = "Microsoft.Jet.OLEDB.4.0"
strDatabasePath = "\\servername\DBPath"
strDatabaseName = "DdatabaseName.mdb"
strDatabasePathName = strDatabasePath & "\" & strDatabaseName
strDBWorkgroupFilePath = "\\servername\WrkGrpPath"
strDBWorkgroupFileName = "WorkgroupFileName.mdw"
strDBWorkgroupPathName = strDBWorkgroupFilePath & "\" &
strDBWorkgroupFileName

strUserID = "A_User_ID"
strUserPassword = "password"

strConnString = "Provider=" & strProviderName & ";" & _
"Data Source=" & strDatabasePathName & ";" & _
"Jet OLEDB:System Database=" & strDBWorkgroupPathName &
";" & _
"User ID=" & strUserID & ";" & _
"Password=" & strUserPassword
Cnn = strConnString
Cnn.Open

Hopefully this is clear.

Thanks for your help, Tom and Jamie.

Regards,
VBA Dabbler

"Tom Ogilvy" wrote:

From the Link:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mydb.mdb;" & _
"Jet OLEDB:System Database=MySystem.mdw", _
"myUsername", "myPassword"

what Jamie Provided:
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=\\ServerName\FolderName\Jet4DB.mdb;
Jet OLEDB:System Database=\\ServerName\Folder2\System_Secured_4.mdw ;
User ID=myID;
Password=mypassword;

is Jet4DB.mdb a place holder like mydb.mdb or does this actually have
special relevance - it has to be Jet4DB.mdb?
( The OP pointed out this line was particularly interesting. )

Is there something special between FolderName and Folder2 or are these
again, just representative placeholders?

Jamie used UserID=, Password=. while the linked example didn't. Must they
be included.

Is System_Secured_4.mdw a literal name that must be used or is it a
placeholder like mysystem.mdw in the link example?

Thanks if you can enlighten me.

--
Regards,
Tom Ogilvy



"VBA Dabbler" wrote in message
...
It works like a charm - the second line of your suggestion was especially
helpful.

Regards,
VBA Dabbler

"Jamie Collins" wrote:


Tom Ogilvy wrote:
the database is on a network share and so is the workgroup
file

Perhaps someone here is an expert on this

In lieu of an expert:

Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=\\ServerName\FolderName\Jet4DB.mdb;
Jet OLEDB:System Database=\\ServerName\Folder2\System_Secured_4.mdw ;
User ID=myID;
Password=mypassword;

I would
recommend posting in an Access newsgroup for a more definitive answer

I wouldn't <g. MS Access is assumed to be always connected to its
database. The average MS Access 'power' user shuns ADO and even some of
the MS Access MVPs don't seem to be able to distinguish between the MS
Access UI and the underlying Jet data engine.

Jamie.

--







 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Data from a secured Access database erick-flores Excel Discussion (Misc queries) 2 November 16th 06 05:31 PM
Help: pivot chart data in secured Access database wont show fields A C Charts and Charting in Excel 0 January 25th 06 01:28 AM
Querying data from Access Steve J Excel Worksheet Functions 0 June 14th 05 10:16 AM
Querying Access Database Edgar Thoemmes Excel Worksheet Functions 1 December 15th 04 01:58 PM
sql.request for secured Access Database record retrieval Theo Fountain Excel Programming 0 July 17th 03 08:14 PM


All times are GMT +1. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"