>Sorry for the non-descriptive subject! I am having trouble with a form that gets it's data in what must be a fairly common way... I will explain...
>I have a form with a grid and a combo...
>My main table (contacts) contains contact information - name address etc
>My second table (companies)contains companies...
>My third table (links) is (what I call) a junction table - a record will have it's own primary key plus a key of a contact and a key of a company thus enabling a many to many relationship.
>So I move to a contact in the contacts table then query the links table to get a list of all the companies they have links with. I loop through the links table extracting the primaries of the companies into a select in statement that queries the companies table to get the details - this populates the grid and works well.
>Next I populate the rowsource of the combo with all the companies so that I have the ability for a contact to move between companies...
>
>Here begins the problem!
>
>I cannot successfully get the combo to display the currently selected (selected in the grid control) company name... the idea being that the user can click on the grid and it displays the company name in the combo - by changing this to another company I need to save the primary of this new company to the links table
>
>I hope this expains well enough my scenario - I have tried different controlsource for the combo but as I say... no joy
>
>I haven't posted code as this post is probably long enough already but will do if required...
Chris,
Since all companies is in combo it's not value missing problem, right ?
If i'd do it actually I'd keep the companykey in grid's recordsource (not just company names though might be).
For combo would have :
with combo
.rowsourcetype = 3
.rowsource = 'select companyName, companyKey '+;
' from companies'+;
' into cursor crsCmps'+;
' order by companyName'
.Columncount = 1
endwith
select crsCmps
locate for companyKey = GridRecSource.Companykey
combo.listindex=recno()
When user chooses a company from combo directly use crsCmps.companyKey to get the key.
Cetin