Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

How to set input parameters for report?

Report uses query that contains input parameters.
When I opens report I dont want to enter it.
How can I set it programmatically?I use VC++.
I opens report by :
m_pDoCmd->OpenReport(COleVariant("Statements"),0,COleVariant(""),COleVariant("UserTrustID="+strIdPath+""));
Can I put it in SQL query as third argument(condition)?And how I must modify this query?
SQL query:
SELECT qryStatements.DivisionCode, qryStatements.DivName, qryStatements.StatementID, qryStatements.StatementCycleYear, qryStatements.StatementCycleMonth, qryStatements.UserTrustID, qryStatements.FoundationName, qryStatements.TrustName, qryStatements.StatementFromDate, qryStatements.StatementToDate, qryStatements.StatementBegBalance, qryStatements.StatementEndBalance, qryStatements.TotalContribution, qryStatements.TotalDistribution, qryStatements.EarningsToDonor, qryStatements.EarningsToGenFund, qryStatements.ChgMktValue, Foundation.pic, qryStatements.Expr1, qryStatements.Rep_Type, qryStatements.DonorName, qryStatements.Donorcsz, qryStatements.DonorAddr1, qryStatements.DonorAddr2, qryStatements.OrgName, qryStatements.DivAddr1, qryStatements.DivAddr2, qryStatements.DivCity, qryStatements.DivState, qryStatements.DivZip, qryStatements.WorkPhone, Foundation.small_logo, qryStatements.web_site, Foundation.StatementFooter
FROM qryStatements INNER JOIN Foundation ON qryStatements.DivisionCode = Foundation.DivisionCode
WHERE qryStatements.StatementCycleYear=[Statement Year] AND qryStatements.StatementCycleMonth=[Statement Month] AND qryStatements.UserTrustID>=[From FundID] And qryStatements.UserTrustID<=[To FundID] AND qryStatements.Rep_Type="Stmnt"
ORDER BY qryStatements.DivisionCode;
Thanks.
0
MByte
Asked:
MByte
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
1. You can point the parameters to a in memory variable with a function call.  ie.

Public Sub SetParam(ByVal InputVal, ByVal ParamID)

    arrParameter(ParamID) = InputVal

End Sub

 before opening the report then redefine the query to do

   GetParam(1)

Public Function GetParam(ByVal ParamID)

    GetParam = arrParameter(ParamID)

End Function

2. You can use a hidden form with controls, populate the controls, then have the select statement reference the form controls

  Forms![myformName]![mycontrolName]


3. You can modify the SQL statement on the fly in the reports Open event and supply the actual values to the string.

Jim.
0
 
1WilliamCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, points to JDettman
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
1William
EE Cleanup Volunteer
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now