INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

PASSING A TEXTBOX VALUE TO A PARAMETER

PASSING A TEXTBOX VALUE TO A PARAMETER

(OP)
Hi Everyone,

Ok. im new to activereports. Heres my problem.

I have a report that reads in lines of info from a DB. What I want to do is, based on the info passed in, take the info from a textbox and pass it to a parameter and then use that paramter to filter my subreport.

EG - Main Report has two text boxes txtCustomerID and txtPaymentType

It also has a paramater called ParamFilters.

Based on what is passed into txtPaymentType, I want to take that and pass that into the parameter which then gets passed into the SQL for my subreport.

Below is my code! Hope some can help!!


public void Detail1_Format()
{

    
     // Get reference to the ServiceCharged sub report control on the main report form
     DataDynamics.ActiveReports.SubReport rptSubCtl = ((DataDynamics.ActiveReports.SubReport) rpt.Sections["Detail1"].Controls["srPaymentTypes"]);
      
      // Create a new ActiveReports report object
      DataDynamics.ActiveReports.ActiveReport3 rptSub = new DataDynamics.ActiveReports.ActiveReport3();
            
      // Load the layout from the report definition file
      rptSub.LoadLayout(((DataDynamics.ActiveReports.SubReport)rpt.Sections["Detail1"].Controls["srPaymentTypes"]).ReportName);
      
      // Create a new datasource object for the sub-report
      DataDynamics.ActiveReports.DataSources.SqlDBDataSource childDataSourcebs= new DataDynamics.ActiveReports.DataSources.SqlDBDataSource();
          
  
  // Copy connection string from the main report
 childDataSourcebs.ConnectionString = ((DataDynamics.ActiveReports.DataSources.SqlDBDataSource)rpt.DataSource).ConnectionString;


  // Set the sub-report query in the datasource
   childDataSourcebs.SQL = "SELECT * FROM PaymentTypes WHERE sPaymentTypeId = '<%paramFilters%>'";
  
  // Assign the data source to the new report object
   rptSub.DataSource = childDataSourcebs;
  
   // Assign sub report to subReport control
  rptSubCtl.Report = rptSub;

   // Pass through main report parameters
  
  rptSub.Parameters["paramFilters"].Value = rpt.Parameters["paramFilters"].Value;


  }


    private void ActiveReport_FetchData(object sender, DataDynamics.ActiveReports.ActiveReport3.FetchEventArgs eArgs)
{
    rpt.Parameters["paramFilters"].Value = rpt.Fields["txtPaymentType"].Value.ToString();
}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close