Recent

Author Topic: [SOLVED] DBLookUpCombo - Assigning DBEdits w/field values issue  (Read 1112 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
I'm having an issue with using a DBLookUpCombo OnCloseUp event assigning additional values to DbEdits. The coding is the same as other forms in this app. but for some reason this particular form is having an error: Field Not Found??? The field exists, ADDRESSLN!! I programmed this as so:
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TFrmProposals.JvDBLukUpCmboClientCloseUp(Sender: TObject);
  3. begin
  4.   DbfProposals.FieldByName('CLIENT').AsString:=
  5.    DbfClients.FieldByName('CUSTOMER').AsString;
  6.   DbfProposals.FieldByName('ADDRESS').AsString:=
  7.    DbfClients.FieldByName('ADDRESSLN1').AsString; //-> Error
  8.   DbfProposals.FieldByName('CITY').AsString:=
  9.    DbfClients.FieldByName('CITYTOWN').AsString;
  10.   DbfProposals.FieldByName('STATEPROV').AsString:=
  11.    DbfClients.FieldByName('STATEPROVINCE').AsString;
  12.   DbfProposals.FieldByName('POSTALCODE').AsString:=
  13.    DbfClients.FieldByName('POSTALCODE').AsString;
  14.   DbfProposals.FieldByName('COUNTRY').AsString:=
  15.    DbfClients.FieldByName('COUNTRY').AsString;
  16. end;
  17.  
  18.  

« Last Edit: March 22, 2024, 06:33:52 pm by 1HuntnMan »

TRon

  • Hero Member
  • *****
  • Posts: 3646
Re: DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #1 on: March 04, 2024, 07:26:21 pm »
Hopefully you are aware that
The field exists, ADDRESSLN!!

is not the exact same as
Quote
   DbfClients.FieldByName('ADDRESSLN1').AsString; //-> Error

Perhaps a typo in your post ?
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #2 on: March 04, 2024, 09:47:33 pm »
TRon,
   Not exactly but, for example this works just fine as in other forms with similar coding for the JvDBLukUpCmbo. Here's an example that works for the OnCloseUp of a JVDBLukUpCmbo:

Code: Pascal  [Select][+][-]
  1. procedure TFrmAppmts.JvDBLukUpCmboCntkCloseUp(Sender: TObject);
  2. begin
  3.   DbfAppmts.FieldByName('CNTKLNAME').AsString:=
  4.    DbfCntks.FieldByName('CNTKLNAME').AsString;
  5.   DbfAppmts.FieldByName('CNTKFNAME').AsString:=
  6.    DbfCntks.FieldByName('CNTKFNAME').AsString;
  7.   DbfAppmts.FieldByName('CNTKMI').AsString:=
  8.    DbfCntks.FieldByName('CNTKMI').AsString;
  9.   DbfAppmts.FieldByName('ADDRESS').AsString:=
  10.    DbfCntks.FieldByName('CNTK_ADRSLN1').AsString;
  11.   DbfAppmts.FieldByName('CITY').AsString:=
  12.    DbfCntks.FieldByName('CNTK_CITY').AsString;
  13.   DbfAppmts.FieldByName('STATEPROV').AsString:=
  14.    DbfCntks.FieldByName('CNTK_STATE').AsString;
  15.   DbfAppmts.FieldByName('POSTALCODE').AsString:=
  16.    DbfCntks.FieldByName('CNTK_POSTALCODE').AsString;
  17. end;
  18.  

This one for the Appointments form works as coded.

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #3 on: March 04, 2024, 10:22:40 pm »
You need to realize that if a field is already present in the select it could be that it is added with a 1 at the end. You normally want to rename those fields in your sql with "as".

Show the sql for both instances and we can tell you if that's the case.

Also, you can check with a sql manager what the resulting fields are really called.
Does it really say ADDRESSLN1?

Or you are working with static fields defined in the tdataset (which I would advice against).

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #4 on: March 04, 2024, 11:17:10 pm »
rvk, not SQL, this is a small single user or maybe 3-4 at the most.  The database is dBase Level 7.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #5 on: March 04, 2024, 11:21:02 pm »
I removed the unit from the Project.  Recreating this form.  I think the issue might be when I created this form, it's similar to another Unit/Form so was copying components from that form to this form and renaming everything.  I think this might have caused the hiccups. It shouldn't take me long. Then I'll be back with the results.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: [SOLVED] DBLookUpCombo - Assigning DBEdits w/field values issue
« Reply #6 on: March 22, 2024, 06:35:50 pm »
Re-created the form/unit and fixed it.  Something I wasn't seeing, oops.

Thanks all...

 

TinyPortal © 2005-2018