borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincani
:: How to Print a Report and open a Form contained in an Access Database

Author  

Andrea Tincani

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
API Declarations

Option Explicit

'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

Usage
'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 "Categories", acNormal, , , , acDialog
End Sub

'Print an Access Report
Private Sub Command2_Click()
    appAccess.DoCmd.OpenReport "Catalog", acViewNormal
End Sub

Private Sub Command3_Click()
    MaximizeAccess
End Sub

'Open a Database
Private Sub Form_Load()
    appAccess.OpenCurrentDatabase "C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb", True
End Sub

'Close the database and the Access Instance
Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    appAccess.CloseCurrentDatabase
    appAccess.DoCmd.Quit acQuitSaveNone
End Sub
:: Navigation

Home

VB and VBA for Word and Access

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 05-03-2010 Using an external image and linking it dynamically on a crystal report by crystal_user
icon 16-12-2008 Crystal Report problem by cci_john
icon 12-05-2008 Re: Printer.? by stickleprojects
icon 18-12-2007 Re: linking 3 tables by Jihadalariqi
icon 16-11-2007 Datareport Question by daggerass
:: Sponsored Links



Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder