How to Open MS Access 2003 Reports With Visual Basic 6

Microsoft Access is a database engine that lets you create reports based on the information stored in your Access tables. You can use these reports to display information in your Microsoft Visual Basic applications. Visual Basic and Access work well together, because Visual Basic has internal functions that call reports and display them without any parsing. Only a few lines of code are required to display your Access reports.

Instructions

    • 1

      Double-click your Visual Basic form file you want to edit. This automatically loads your coding software and opens the form you want to use to display the report.

    • 2

      Double-click the form to open the code. Create the report object and open the report. To accomplish this task, type the following code to start the reporting process:

      access = New Access.ApplicationClass()

      access.OpenCurrentDatabase(filepath:="c:\accessdb.mdb", Exclusive:=True)

      Replace "c:\accessdb.mdb" with the location of your own Access database file.

    • 3

      Add the code to display the report. Type this code below the code created in Step 2:

      access.DoCmd.OpenReport(ReportName:="Sales", View:=Access.AcView.acViewPreview)

    • 4

      Click the "Save" button. Click "Run" to view your new form changes and display the report in your Visual Basic application.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured