routerboy309
asked on
Locating a Part Location based on part number
I'm tring to find a Part Location based on a Part number thats entered in a standard Edit Box. Here's what I have:
procedure TMainForm.FindPartLocation Click(Send er: TObject);
begin
DataModuleForm.PartID.Open ; // Make sure its open first
PartNumber.Text := DataModuleForm.PartIDPartN umber.AsSt ring; //An Edit Box to perform the locate
DataModuleform.PartID.Loca te('Locati on', Edit1.Text ,[]);
ShowMessage('Part Number is stored at ' + DataModuleForm.PartIDPartL ocation.As String);
DataModuleForm.PartID.Clos e; // Now lets close it
end;
But it always retuns the same Part Location no matter what Part Number I enter. Any one have a clue to what I'm doing wrong?
procedure TMainForm.FindPartLocation
begin
DataModuleForm.PartID.Open
PartNumber.Text := DataModuleForm.PartIDPartN
DataModuleform.PartID.Loca
ShowMessage('Part Number is stored at ' + DataModuleForm.PartIDPartL
DataModuleForm.PartID.Clos
end;
But it always retuns the same Part Location no matter what Part Number I enter. Any one have a clue to what I'm doing wrong?
I think you must build an index on Location too!, and I'm not sure if you need the final parameter to be [lopartialkey]....
Rob ;-)
Rob ;-)
ASKER
Indexing did the trick. (Big Smile). Is adding this type of control to the DBGrid basically the same method? (where in the events do I add the code?. I added it to OnCellClick and it always go to the last entry) RBertora - please send the grade sheet.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
RBertora
I added the code to a DBGrid (on CellClick event). I wanted to use either the TButton or if a user clicks on the DBGrid, the edit box would update the location. But something with the Grid or my code (more so) is causing the cursor to jump to the either the last record or the first record and is failing to update the field....Weird. I have remove all instances and it still happens. Wonder if its the table opening and closing?
I added the code to a DBGrid (on CellClick event). I wanted to use either the TButton or if a user clicks on the DBGrid, the edit box would update the location. But something with the Grid or my code (more so) is causing the cursor to jump to the either the last record or the first record and is failing to update the field....Weird. I have remove all instances and it still happens. Wonder if its the table opening and closing?
try to use a local var
procedure TMainForm.FindPartLocation
var s : String;
begin
s := Edit1.Text;
DataModuleForm.PartID.Open
PartNumber.Text := DataModuleForm.PartIDPartN
//An Edit Box to perform the locate
DataModuleform.PartID.Loca
ShowMessage('Part Number is stored at ' + DataModuleForm.PartIDPartL
DataModuleForm.PartID.Clos
end;
meikl