CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Location
    Portugal
    Posts
    7

    Acessing Database Using Acess.Aplication object

    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


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Acessing Database Using Acess.Aplication object

    '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
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Location
    Portugal
    Posts
    7

    Re: Acessing Database Using Acess.Aplication object

    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


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Acessing Database Using Acess.Aplication object

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured