Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the grid in a more to more relationship?

Status
Not open for further replies.

RedLion

Programmer
Sep 13, 2000
342
NL
Hello,
I'm just new in VFP, so I don't now where to look. The situation is that a company has several company's whith one or more contactpersons for that company. A contactperson can be the person for more company's. I've one table with company's (comp_id) and a table employee (emp_id)and a table whith comp_id an emp_id as foreign keys.

company --< comp_emp >-- employee && tables
comp_id --< comp_id, cust_id >-- emp_id && atributes
name name
e-mail e-mail

above the grid I've placed the comp in textboxes, and the problem is how do I fill the grid with the table employee. where do I've to set the linkmaster to???? to comp_emp or company??? It isn't working! I now it is a silly simple thing, but I don't know it! I've already looked for something like data-control as in VB, but I can't find it!

So Please help me???????

RedLion
RedlLion@dolfijn.nl
[sig][/sig]
 
It may be that the easiest solution is to throw in a couple of lines of code.

Make the grid's recordsource an Alias; on the combobox valid (or interactivechange) execute a select statement that joins your comp_emp to employee for the chosen company and puts the result in the RecordSource for the grid. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Thank you
but I'm doing something wrong, because I can't get anything in the grid now. To browse between the company records I use cmd buttons, which calls the refresh method from the main form. In refresh I've written:

thisform.myCustomerGrid.recordsource = &quot;select customer.name, customer.e_mail from employee, company, comp_emp where (company.comp_id = txtComp_id.text) and (company.comp_id = comp_emp.comp_id) and (comp_emp.emp_id = employee.emp_id)&quot;

The only settings I've set in the grid are:
childorder = employee.emp_id
linkmaster = company
recordsourcetype = 1 - Alias


What am I doing very wrong????
Please tell me? [sig][/sig]
 
If you are going to use an actual SQL statement as the RecordSource, you'll need to set the RecordSourceType to 4 - SQL Statement. What I was proposing is a bit different, but this may work fine for you. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
I'm sory, but it's still not working, not with alias or SQL. I'm doing something terrible wrong, but I don't know what? I've tried everything but it's not working at all?????????????

At the post before I've written exactly what I've done, (I haven't done anything more then the code above) but that isn't working.

Mr Bradley in the post before you said that I had to put the recorsource to 1 - Alias and then to use a select statement to fill the recordsource, but what did you meant exactly???

Thanks for your help before, but I need a little more help, please???????????????? [sig][/sig]
 

RedLion, Please, understand than most is depended on your effort, not our.
1. From code samples above I see that you mix manua refreshing with automatic refreshing of 2 related grids. DO NOT DO THIS. Do completely automatic refreshing OR completely manual.
2. In the saples for VFP MS put special form with 2 related grids. Open it in design-time and look to properties of grids. Look to tables structure and indexes. It works in sample. Why it does not works in you application? We cannot determinr this, because no much of information you provided.
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top