I created a VB6 program which I linked to MS-Access(.mdb) using AdoData Control. I created a Data Report which displays all the records in the table.
Now, I want to be able to FILTER any desired record (e.g anybody with a particular FIRSTNAME ) . This means, any time I want to display the records of those with FIRSTNAME = JOHN then I will type JOHN in a textbox control and filter their records alone in the Data Report.
I need your help to achieve this!!!!!!!!!!!
This is very very urgent
Thanks for your concern
Data Report
Page 1 of 110 Replies - 1896 Views - Last Post: 18 April 2012 - 12:42 PM
Replies To: Data Report
#2
Re: Data Report
Posted 09 April 2012 - 07:58 AM
I would suggest that attempting to get expedited help by talking about how very, very urgent your particular problem is in comparison to the other folks that need help has the opposite effect of the effect intended, because it offends people in much the same way that people who attempt to take cuts in line offend people.
Now, your ADO Data Control has a Recordset property. The Recordset property has a Filter property. Setting the filter property to a valid SQL WHERE clause will have the effect you desire. Setting it back to empty string will clear it.
Now, your ADO Data Control has a Recordset property. The Recordset property has a Filter property. Setting the filter property to a valid SQL WHERE clause will have the effect you desire. Setting it back to empty string will clear it.
#3
Re: Data Report
Posted 09 April 2012 - 08:19 PM
BobRodes, on 09 April 2012 - 07:58 AM, said:
I would suggest that attempting to get expedited help by talking about how very, very urgent your particular problem is in comparison to the other folks that need help has the opposite effect of the effect intended, because it offends people in much the same way that people who attempt to take cuts in line offend people.
Now, your ADO Data Control has a Recordset property. The Recordset property has a Filter property. Setting the filter property to a valid SQL WHERE clause will have the effect you desire. Setting it back to empty string will clear it.
Now, your ADO Data Control has a Recordset property. The Recordset property has a Filter property. Setting the filter property to a valid SQL WHERE clause will have the effect you desire. Setting it back to empty string will clear it.
I have a Filter SQL code which works fine with the DataGrid. If I type any text in the textbox control and click on a button (e.g cmdFilter) it filters the correct records and the DataGrid Shows the filtered records but the problem is that of the Data Report; the Data Report shows all the records in the table and not the filtered records.
I need a situation whereby as I type any LNAME in the textbox control on my FORM and click
a button (e.g cmdFilter) then it will filter the LNAME so that the Data Report can also
display the same filtered records and not all the records in the table.
#4
Re: Data Report
Posted 10 April 2012 - 06:20 AM
Well, so long as I require top secret security clearance to see your code, I'm afraid I will have to refer you to my previous post with no further elaboration.
#5
Re: Data Report
Posted 10 April 2012 - 03:39 PM
Private Sub cmdFilter_Click()
On Error Resume Next
With Adodc1.Recordset
.MoveFirst
.Filter = "surname= '" & txtsearch.Text & "'"
If .EOF Then
MsgBox "Invalid Data", vbOKOnly, "Search info"
Adodc1.Refresh
Else
End If
End With
End Sub
here is the Filter Code that I used
This post has been edited by BobRodes: 11 April 2012 - 12:50 PM
#6
Re: Data Report
Posted 11 April 2012 - 12:59 PM
All right, that's better. Now, please edit your post and see how I added in code tags, and use them in future if you would. Now you're better off using If .EOF And .BOF Then when checking for an empty recordset, because in no case will this be true unless the recordset is empty. Next, if this condition happens, you'll want to clear the filter: .Filter = "". Otherwise, your code looks fine.
So, you're probably setting up your DataSource for your DataReport to be a DataEnvironment, which doesn't have the filter applied to it, and need to set it to your DataReport. Are you setting your DataSource to your recordset in the Initialize event of the DataReport object, or are you doing something else?
So, you're probably setting up your DataSource for your DataReport to be a DataEnvironment, which doesn't have the filter applied to it, and need to set it to your DataReport. Are you setting your DataSource to your recordset in the Initialize event of the DataReport object, or are you doing something else?
#7
Re: Data Report
Posted 11 April 2012 - 03:21 PM
Thanks for the Reply
I created the Data Report with DataEnvironment;
I actually set up the DataSource for the DataReport to be a DataEnvironment (In the Property window of the Data Report);
I did not set the DataSource to the recordset in the Initialize event of the DataReport object (There is no code in the Initialize event of the DataReport object);
You said that what I did doesn't have the filter applied to it, and need to set it to the DataReport;
I am a beginner in VB6 and I don't know how to correct the mistakes that you pointed out;
I need your assistance in correcting the mistakes. Thanks
I created the Data Report with DataEnvironment;
I actually set up the DataSource for the DataReport to be a DataEnvironment (In the Property window of the Data Report);
I did not set the DataSource to the recordset in the Initialize event of the DataReport object (There is no code in the Initialize event of the DataReport object);
You said that what I did doesn't have the filter applied to it, and need to set it to the DataReport;
I am a beginner in VB6 and I don't know how to correct the mistakes that you pointed out;
I need your assistance in correcting the mistakes. Thanks
#8
Re: Data Report
Posted 12 April 2012 - 08:03 AM
Ok. Your problem is that you have set up your filter on the recordset of your data control. Then you have set up a DataEnvironment independently of the control, and tied your DataReport to it. How are you getting your data control to relate to your DataReport exactly? I may be a bit foggy here, as it has been perhaps 10 years since I messed with a DataEnvironment.
The simplest way is to not use the DataEnvironment, and go into the Initialize event of the DataReport and set its DataSource property to the DataControl's Recordset property. That should allow your filter to apply to the report data.
The simplest way is to not use the DataEnvironment, and go into the Initialize event of the DataReport and set its DataSource property to the DataControl's Recordset property. That should allow your filter to apply to the report data.
This post has been edited by BobRodes: 12 April 2012 - 08:06 AM
#9
Re: Data Report
Posted 13 April 2012 - 04:59 PM
I created a new Data Report and added this code in the Initialize event;
I executed the program and got this error message;
Compile Error:
Method or data member not found
Now I added Set keyword to the code;
I executed the program and got this error message;
Run-time error '424'
Object required
Please, I don't know what next to do in order to solve this problem
Private Sub DataReport_Initialize() DataReport1.DataSource = Adodc1.Recordset End Sub
I executed the program and got this error message;
Compile Error:
Method or data member not found
Now I added Set keyword to the code;
Private Sub DataReport_Initialize() Set DataReport1.DataSource = Adodc1.Recordset End Sub
I executed the program and got this error message;
Run-time error '424'
Object required
Please, I don't know what next to do in order to solve this problem
#10
Re: Data Report
Posted 17 April 2012 - 06:17 AM
I'm sorry, but I'm not too familiar with DataReports. Do they have a Load event? If so, move the statement from the Initialize event to the Load event. Also, you could try putting this in the Form_load event.
The problem is (probably) that the objects are being referred to before they get started up.
The problem is (probably) that the objects are being referred to before they get started up.
#11
Re: Data Report
Posted 18 April 2012 - 12:42 PM
Just because I said I'm not too familiar with DataReport doesn't mean that my suggestions aren't worth investigating. I'm actually VERY familiar with your problem, comes up a lot in Initialize events and even in Load events sometimes.
So, suppose you quit necroposting and hijacking old threads and try the things I suggested.
So, suppose you quit necroposting and hijacking old threads and try the things I suggested.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|