Click to See Complete Forum and Search --> : Linking Datagrid
adam01
Aug 18th, 2000, 05:59 AM
Hello. I have a form where I have opened two different recordsets adRouterM and adRouterS. They are linked to two seperate Access 2000 database tables. I created two datagrids to display the recordsets on the form. However, I cannot figure out how I can link a field on the form to refresh or requery the results of the datagrids to only include variances of that field value. i.e. If my form has a field (PartNum) with a value of "X1234", then the datagrids should both only show records with that value. Thanks for any help in advance.....
davidrobin
Aug 18th, 2000, 06:17 AM
I don't know how you are binding the gatagrids to the database but I would suggest you use an SQL query to filter out the desited records.
These previous posts should give more info:
http://forums.vb-world.net/showthread.php?threadid=26564
http://forums.vb-world.net/showthread.php?threadid=26740
adam01
Aug 18th, 2000, 08:12 AM
Thanks for the quick response David. I used the previous links to create my dataenvironment, it worked great. However, I still do not know the actual code to link the field on a form to requery the datagrids. As I browse through my recordset with my ado navigational controls I wish to have the information update automatically. Maybe I am missing something, it's probably easy! Thanks.
davidrobin
Aug 18th, 2000, 08:37 AM
Let me see if I understand you right.
You have a button which changes the value of a field on a form. You want the datagrids to only display the records where there is a match between the field and a value in the record. You are using a Data Environment rather than code to set up your data source.
What do you mean by a field on the form?
adam01
Aug 18th, 2000, 09:34 AM
David, There is no button on my form. Consider it like an MS Access Subform scenario where I want the value of a text box on my screen (PartNum) to link the two datagrids together showing only instances of that particular value (PartNum). The two datagrid datasources are MS Access Tables in my database. As my user clicks through the recordset, the text boxes change reflecting the next record in the recordset. I want the datagrids to be linked to that PartNum Text Box. Thanks again.
PJB
Aug 18th, 2000, 09:41 AM
Not sure i understand but I think if you setup one table as a child command of the other in your DataEnvironment you will have to set your relationship there , just have it relate PartNo. to PartNo.
Dunno if that's along the lines your looking for or not
davidrobin
Aug 18th, 2000, 10:52 AM
This one has had me confused for a while but this is how i managed to sort it.
if you have your dataenvironment return all records you can filter out the required matching records like this depending on the contents of the textbox. Place this in the onchange event of the textbox. The ISBN number is the field you want to match in your datagrid. Repeat the code for the second datagrid.
DataEnvironment1.rsCommand1.Filter = " ISBN = " & RTrim(Text1.Text)
DataGrid1.Refresh
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.