ProgrammingMSAccess.com

Learn about Developers Group
Join Developers Group
Order SPAM Blocker
Free Stuff
Guest Book
.NET Resources
SQL Server Resources
Favorites
Technical Support
Books & DVDs by Webmaster
Articles, tutorials, & more
FAQs
Product Reviews
Samples
Prior Newsletters
Contact Us
Home
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

a PAIR OF PROCEDURES FOR PROGRAMMATICALLY OPENING AN ACCESS PROJECT WITH INTEGRATED SECURITY.  rEPLACE THE SRVNAME, DBNAME, PRPATH, AND PRNAME ARGUMENTS WITH SETTINGS APPROPRIATE FOR YOUR COMPUTING ENVIRONMENT.  YOU CAN RUN THESE PROCEDURES FROM ANY Vba PROCEDURE TO AUTOMATICALLY OPEN AN ACCESS PROJECT CONNECTED TO A DATABASE OF YOUR CHOICE

Sub CallOpenADPWithWindowsLogin()
Dim srvname As String
Dim dbname As String
Dim prpath As String
Dim prname As String

'Set parameters for routine to open Access project
srvname = "CABLAT"
dbname = "SecurityDemo1"
prpath = "C:\Documents and Settings\Administrator\My Documents\"
prname = "msdn_security_test"

OpenADPWithWindowsLogin srvname, dbname, prpath, prname

End Sub

Sub OpenADPWithWindowsLogin(srvname As String, dbname As String, _
prpath As String, prname As String)
Const strConPathToSamples = "C:\Documents and Settings\Administrator\My Documents\"

Dim frm As Form, strDB As String

'Instantiate Access session (use .9 for Access 2000
'and .10 for Access 2002)
Set appAccess = CreateObject("Access.Application.9")

'Open project with login and password from last use
'and show it
'prpath = "C:\Documents and Settings\Administrator\My Documents\"
'prname = "msdn_security_test"
strPrFilePath = prpath & prname
appAccess.OpenAccessProject strPrFilePath
appAccess.Visible = True

'Set for Windows login
appAccess.CurrentProject.OpenConnection _
"PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;" & _
"PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=" & _
dbname & ";DATA SOURCE=" & srvname

'Close Access session object
appAccess.CloseCurrentDatabase
Set appAccess = Nothing

End Sub

Want to understand  Microsoft Access 2000 so that you can program it to do more tasks like this?  Get Professional SQL Server Development with Access 2000 by Rick Dobson from Wrox Press.  Learn more about the book by clicking here.

Copyright 2001 CAB, Inc. All rights reserved. Republication or redistribution of CAB, Inc. content, including by framing or similar means, is expressly prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be liable for any errors in the content, or for any actions taken in reliance thereon.