Request for help - Calling Access report from Visual Basic application

gellerche

Registered User.
Local time
Today, 17:32
Joined
Jun 19, 2001
Messages
73
I want to call an Access report from Visual Basic. In the VB app, the user decides what parameters to be set when the report is run (eg. 'Name' = 'Bob' or 'City' = 'Chicago'). After the user selects the desired options, the code generates the SQL statement.

I've read the posts about how to call the report from VB, and understand how to do that. The problem is that the report's underlying query can change (sometimes they select Name, sometimes City, etc.), since the user has different options to select. Therefore, I can't have the report call the same static query each time.

Is there a way to pass the SQL statement from VB to Access?

Thank you,

Steve Geller
 
I found out how to do this:

SQL = "ParentSoftware = '" & Me.cboSoftware & "' "

Dim AccessObj As New Access.Application
With AccessObj
.OpenCurrentDatabase gblDatabaseLocation, False
.DoCmd.Maximize
.Visible = True
.DoCmd.OpenReport "rptSoftwareInventory", acViewPreview, , SQL
End With
 
I found out how to do this:

SQL = "ParentSoftware = '" & Me.cboSoftware & "' "

Dim AccessObj As New Access.Application
With AccessObj
.OpenCurrentDatabase gblDatabaseLocation, False
.DoCmd.Maximize
.Visible = True
.DoCmd.OpenReport "rptSoftwareInventory", acViewPreview, , SQL
End With
 

Users who are viewing this thread

Back
Top Bottom