team2005
asked on
How to use Openreport from vb6, with parameters ?
Hi!
Have a vb6.0 project that calls different reports that are stored in a access db.
What i need is a way to call a report with one or more parameters.
How can i do this, please give me the source-code for calling reports with parameters.
Her are the code i use today (without parameters)
oAcc.DoCmd.OpenReport ReportName:=strReportName, & _
View:=acNormal
Need this code today.
Thanks.
Tor
Have a vb6.0 project that calls different reports that are stored in a access db.
What i need is a way to call a report with one or more parameters.
How can i do this, please give me the source-code for calling reports with parameters.
Her are the code i use today (without parameters)
oAcc.DoCmd.OpenReport ReportName:=strReportName,
View:=acNormal
Need this code today.
Thanks.
Tor
ASKER
Hi!
Need code to start a report with parameters, not to start a report ?
Her are the code i use today (without parameters)
oAcc.DoCmd.OpenReport ReportName:=strReportName, & _
View:=acNormal
Need to call report with parameters min. 2 parameters. Found out that i can
use this code:
strWhere = "SORTSEQ >=" & "100"
With oAcc
.Visible = False
.DoCmd.OpenReport strReportName, acViewPreview, , strWhere
.DoCmd.PrintOut
End With
Working just fine with 1 parameter, but how do i use it with more then one parameter.
If you can give me the code to do that, i give you the 500 points.
Thanks
Tor
Need code to start a report with parameters, not to start a report ?
Her are the code i use today (without parameters)
oAcc.DoCmd.OpenReport ReportName:=strReportName,
View:=acNormal
Need to call report with parameters min. 2 parameters. Found out that i can
use this code:
strWhere = "SORTSEQ >=" & "100"
With oAcc
.Visible = False
.DoCmd.OpenReport strReportName, acViewPreview, , strWhere
.DoCmd.PrintOut
End With
Working just fine with 1 parameter, but how do i use it with more then one parameter.
If you can give me the code to do that, i give you the 500 points.
Thanks
Tor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi!
Thats working 100%, thanks.
Cheers,
Tor
Thats working 100%, thanks.
Cheers,
Tor
There's a great tip on it:
http://www.andreavb.com/tip110002.html
Quote for You the essense:
You'll need the API and Access bind as You probably allready know:
'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
'Print an Access Report
Private Sub Command2_Click()
appAccess.DoCmd.OpenReport
End Sub
'Open an Access Form
Private Sub Command1_Click()
appAccess.DoCmd.OpenForm "Categories", acNormal, , , , acDialog
End Sub
Hope It helps
Cheers!