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!

Updating a grid column from a lookup

Status
Not open for further replies.

SteveMacPSU

Programmer
Sep 8, 2005
32
US
Hello,

I've been wrestling with this problem for some time now and I look to the experts for help. I have a form that contains a grid of a few of the fields that exist in my record for a quick view. I display that information and the remaining pertinent information of the current record below the grid for a more detailed view and a place to add and edit. Below the grid I have a combo box that is used to update a status code of the current record. The combo box links the code with a 'lookup' description in another table and displays that information perfectly. I can not for the life of me get the corresponding information to display in the grid column. Again, I have a code in my main table (status) that links to a code in a lookup table and I would like to display the description from the lookup table in the column on the grid. Thanks for your anticipated help.

 
I can not for the life of me get the corresponding information to display in the grid column. Again, I have a code in my main table (status) that links to a code in a lookup table and I would like to display the description from the lookup table in the column on the grid.

Set up the controlSource for your grid column liek this:

Code:
( IIF( SEEK( GridRecordSource.FK_Field, [Lookup_table], [Lookup_pk] ), LookupTable.Description, [] ) )


Marcia G. Akins
 
Marcia,

Thanks for your prompt reply. I had actually seen your response to this on another site and tried it. I obviously can't figure out the ('s and ['s and _fk's. I tried a lot of different combinations but just kept getting the error message that the record source had to be a variable name. So at the risk of seeming extremely stupid I give you....

acontact.role = code to lookup numeric,2

lookup table / index = mct / mct

the lookup table has a prefix associated with the record so that multiple systems codes can be maintained in this table.

MCT table structure

Prefix C 3
code N 2
Name C 30

this is my best try (that didn't work)

( IIF( SEEK( "ROL" + str(acontact.role,2), [mct], [mct] ), mct.name, [] ) )

Hopefully I'm just a semi-colon, or a misplaced bracket away! away

 
try indexseek()
llPoint=.T.
lcSeek="ROL" + TRANSFORM(acontact.role)

=iif(indexseek(lcSeek,llPoint,"MCT","MCT") , MCT.NAME," ")


David W. Grewe Dave
 
( IIF( SEEK( "ROL" + str(acontact.role,2), [mct], [mct] ), mct.name, [] ) )"

change to:
First make sure the lookup table has the right index set
next in the control source of the description column:

=iif(seek("ROL" + str(acontact.role,2),"mct"),mct.name,"")

In your combobox Valid()
thisform.grid.refresh
 
Thanks to all!

I finally got it with this (thanks to all the feedback)....

( IIF( SEEK( "ROL" + STR(acontact.role,2), "MCT", "MCT" ), mct.name, "n/a" ) )

That has had me stumped for sometime, and since I use this technique though out the application I was getting very frustrated. Again thanks to one and all, I'm sure I'll be back soon with another....
 
I was having the exact same problem using the same CA for the grid and for the combobox. In combobox InteractiveChange event I put the following code:
Code:
replace cHardware WITH this.DisplayValue, iHardware_Code WITH this.value IN crsAllProblems
this.Parent.grdAllProblems.Refresh()

and this solved the problem for me. BTW, it was suggested by Borislav Borissov in another forum.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top