PDA

Click to See Complete Forum and Search --> : i want to access a report ina database from my vb forms


jasmine
May 7th, 2008, 03:11 PM
hi

i have created some forms in visual basic and i wanted to create a command button to access a report in my Access Database

how do i do this??

RhinoBull
May 7th, 2008, 03:46 PM
The only way is if you automate MS Access (that means MS Access must be installed on user's machine).
Here is a quick sample - make changes as necessary.

Public Sub RunAccessReport(strDB As String, strReport As String, _
Optional strFilter As String = "", _
Optional strWhere As String = "")
'===================================================================
Dim AccessDB As Object

Set AccessDB = CreateObject("Access.Application")
AccessDB.OpenCurrentDatabase strDB

AccessDB.DoCmd.OpenReport strReport, acViewPreview, strFilter, strWhere
AccessDB.DoCmd.PrintOut acPrintAll

'''AccessDB.DoCmd.PrintOut acPages, 1, 1

'''AccessDB.Visible = True
Set AccessDB = Nothing

End Sub

'sample usage:
RunAccessReport App.Path & "\mydb.mdb", "Report1"

Hack
May 8th, 2008, 06:04 AM
Moved to Reporting