[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to use Openreport from vb6, with parameters ?

Posted on 2005-04-10
4
Medium Priority
?
935 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:team2005
  • 2
4 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 13747960
Hi team2005,
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 "Catalog", acViewNormal
End Sub

'Open an Access Form
Private Sub Command1_Click()
    appAccess.DoCmd.OpenForm "Categories", acNormal, , , , acDialog
End Sub

Hope It helps
Cheers!
0
 
LVL 2

Author Comment

by:team2005
ID: 13748150
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
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 13748551
strWhere = "SORTSEQ >= 100 AND FieldName2 = ThisValue"
0
 
LVL 2

Author Comment

by:team2005
ID: 13748834
Hi!

Thats working 100%, thanks.

Cheers,
Tor



0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question