We help IT Professionals succeed at work.
Get Started

DBgrid Lookup field problem

jarty67 asked
Last Modified: 2008-03-10
in a DBGrid related to sql server the lookup column behaves strangely, when
I select a value from the list it does not appear in the cell, is there any

I am using Delphi 7 and msde

Grid works like this the user selects a car manufacturer from a field for witch I fill the pick list when the form loads...that
works fine and does update, the next field is filled the same way when the car manufacturer changes
...when the user selects part, whose value depend on the manufacturer and model selected
the drop down is filled with the right information but the part selected
from the drop down is blank even when I exit the cell....

here are my two tables:
Detailstbl attached to dbgrid
Name       Type                     Length      
TblId     int     4     0                      Key
ProformaID     int     4     1    
ManuShotName     char     30     1    
ModelName     char     30     1    
PartID     numeric     9     1    
PartName     varchar     40     1    
UnitPrice     money     8     1    
Quantity     smallint     2     1    
Discount     money     8     1    
facteurPid     int     4     1
and PartsQry:
Select PartId,PartName,Location,PartUnitPrice,
PartQtyOnHand,PartQtySold,FacteurPID from PartsStock where ManuShortName = :Manu and ModelName = :Model

in code set the shortname and model the following way in the Tform1.ADOPDetailsModelNameChange event:

col1txt := DBGrid1.Columns[1].Field.AsString;
col2txt := DBGrid1.Columns[2].Field.AsString;
QryPart.Parameters[0].Value := Col1txt;
QryPart.Parameters[1].Value := Col2txt;
QryPart.Active := True;
Watch Question
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE