?
Solved

Send parameter to VB Data Report (VB 6.0)

Posted on 2004-09-08
10
Medium Priority
?
726 Views
Last Modified: 2012-06-21
I'm developing a simple system which uses VB for the interface + data report and MS ACCESS as the database.  I have created an interface for searching purpose and manage to create a data report from VB.  My problem is that...i'm suppose to send a parameter from the searching screen as to filter the result data in the data report.... i do not know how...  

This will be the database query:
SELECT     ItemName
FROM         dbo.tblmstExpenses
WHERE     (MONTH(ReceiveDate) = @date)


The Questions will be:
1.  Can anybody help me to integrate the Searching Interface with the Data Report by sending a parameter from the Searching Screen.  

2.  Do I have to add-in any References or Components...

3.  Help me with the steps and syntax please....

Thank You





0
Comment
Question by:hernaezia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
10 Comments
 
LVL 13

Expert Comment

by:Michael_D
ID: 12012016
You can use ADO.

'create Connection Object
Dim cn As New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<yourMDBfile.mdb>
cn.Open
Dim rs As New ADODB.Recordset

Dim sSql as string
sSql= "SELECT     ItemName " & _
"FROM         dbo.tblmstExpenses " & _
"WHERE     (MONTH(ReceiveDate) = " & txtMonth.text ' or whatever your criteria from

'open recordset
rs.Open sSql, cn, adOpenStatic, adLockOptimistic, adCmdText

Set DataReport1.DataSource = rs

'then bind your data reports fields with  rs fields
With DataReport1.Sections("section1")
    .Controls("col1").DataField = "ItemName"
End With

DataReport1.Show


I hope this help.
regards,

Michael
0
 

Author Comment

by:hernaezia
ID: 12012613
Michael, it seems like i'm a bit confused with this portion

With DataReport1.Sections("section1")
    .Controls("col1").DataField = "ItemName"
End With

can you please explain a bit this protion....becoz it seems that i do not understand the sections and controls part...
0
 

Author Comment

by:hernaezia
ID: 12012626
Michael, do i have to declare the ("section1") and ("col1") part somewhere in the coding,
when i generate my coding, this message appears "The Object ''Section1 " was not found".
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Accepted Solution

by:
x50Fade earned 1000 total points
ID: 12014715
All that you need to do is to access the controls on the datareport..which works a littlebit different from accessing controls on a differetn form.

With DataReport1.Sections("section1")
    .Controls("col1").DataField = "ItemName"
End With


The Section1 is the section where the control(label) is that you want to access...your's might be section 2 or 5, just check on your datareport.

theControls("Col1") means the actual control that you want to access, your's might be lblItemName or whatever....

Hope this helps
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12015781
Ok, looks like x50Fade's answer covers everything.
but anyway...

Section1 is default Details section on Data Report. you can rename it as any other control. So check what name you have for Details Section ( it should be like "Details (theActualName)" ).
put RptTextBox Controls on Detail Section. There  will appear your report's data. Rename those controls if you wish. That name comes instead of "col1" in my example.
 
0
 
LVL 2

Expert Comment

by:x50Fade
ID: 12016070
As I said...hehe
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12562540
I gave full solution and x50Fade helped as well.
I think split will be fair.
0
 
LVL 2

Expert Comment

by:x50Fade
ID: 12562873
I agree
0
 

Author Comment

by:hernaezia
ID: 12622039
i'm sorry guys im out of town for 2 weeks..n i didnt get a chance to login to this site..sorry guyss n thankss alot...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

752 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