Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to Print a Report and open a Form contained in an Access Database

Total Hit ( 2737)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


API Declarations

Click here to copy the following block
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

Click here to copy the following block
'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


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.