Paulo Filipe
April 9th, 2001, 11:20 AM
I would like to know how to open an Acess Database protected by a password, using Acess.Aplication object without being asked by the password
|
Click to See Complete Forum and Search --> : Acessing Database Using Acess.Aplication object Paulo Filipe April 9th, 2001, 11:20 AM I would like to know how to open an Acess Database protected by a password, using Acess.Aplication object without being asked by the password Iouri April 9th, 2001, 01:24 PM 'connection to secure database Dim Cnn As ADODB.Connection Dim Rst As ADODB.Recordset 'In the place where you want to establish your connection, such 'as the Initialize event of a class module, enter the following: Dim strConnect As String Set Cnn = New ADODB.Connection 'Substitute your own User IDs, Password, Data Source, and System 'database in the connection string below strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Password=MyPassword;User ID=Administrator;" & _ "Data Source=C:\AccessDBs\DB1.mdb;" & _ "Persist Security Info=True;" & _ "Jet OLEDB:System database=C:\AccessDBs\system.mdw" With Cnn .CursorLocation = adUseClient .Open strConnect End With Set Rst = New ADODB.Recordset Rst.ActiveConnection = Cnn Iouri Boutchkine iouri@hotsheet.com Paulo Filipe April 10th, 2001, 11:44 AM thank you very much for your help, but the purpose of using the acess.Aplication object instead of the Microsoft Acess Data Objects is that the first object allows you to call acess forms and reports stored in the database Iouri April 10th, 2001, 12:23 PM To call form and reports you can do as following: 'API Declarations Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'API Message Constants Private Const SW_MAXIMIZE = 3 Private Const SW_NORMAL = 1 'add the Microsoft Access 8.0 Object Library to the project references...Create a Form with three Command Buttons and enjoy with this code 'Create a new Access Instance Dim appAccess As New Access.Application Public Sub MaximizeAccess() '===================== 'Maximize Access Application Dim hWnd As Long hWnd = FindWindow("OMain", "Microsoft Access") If hWnd <> 0 Then ShowWindow hWnd, SW_NORMAL ShowWindow hWnd, SW_MAXIMIZE End If End Sub 'Open an Access Form '===================== Private Sub Command1_Click() appAccess.DoCmd.OpenForm "PRQ", acNormal, , , , acDialog End Sub 'Print an Access Report '===================== Private Sub Command2_Click() appAccess.DoCmd.OpenReport "rptPRQ", acViewNormal 'print End Sub Private Sub Command3_Click() MaximizeAccess End Sub Private Sub Command5_Click() appAccess.DoCmd.OpenReport "rptPRQ", acPreview 'preview Call MaximizeOutput End Sub Private Sub MaximizeOutput() ' Maximize the report window appAccess.DoCmd.Maximize ' Show the Access window appAccess.Visible = True End Sub Iouri Boutchkine iouri@hotsheet.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |