Page 1 of 1

Get row of data from datagrid bases on the name in Col 1.

Posted: Thu Feb 23, 2023 2:04 pm
by CAsba
Hi, I've set up a simple name and address, etc., datagrid table. The user enters name, etc details by a series of ask dialogs, and a customer code is generated - 3 or 4 characters, then the whole is entered into the datagrid. The customer code is in col 1 of the table.
When the user wants to raise a document for a customer (invoice/delivery note, etc) he selects the customer code from a combo menu that puts the cust. code into a field. The system should then use the field to get the cust. data to put into address fields on the document.
I've tried interpreting suggestions from previous forum submissions, and looked up the lessons, but without success.
Can anyone give me a simple piece of code to do the trick ?

Re: Get row of data from datagrid bases on the name in Col 1.

Posted: Thu Feb 23, 2023 2:45 pm
by Klaus
Hi CAsba,

I presume the customer code is a unique number, right?
Then you could use LINEOFSSET or FILTER.
Lineoffset:

Code: Select all

...
put fld "the one with the code" & TAB into tCode
put the dgtext of grp "all addresses etc..." into tText
put lineoffset(tCode,tText) into tline
if tLine = 0 then
  beep
  answer "No such code!"
  exit to top
end if
put line tLine of tText into tFoundLine
set itemdel to TAB
## Now you have the line and can extract all wanted columns from tFoundLine
...
FILTER:

Code: Select all

...
## Same as above but we also add a WILDCARD -> *
put fld "the one with the code" & TAB & "*" into tCode
put the dgtext of grp "all addresses etc..." into tText
filter tText with tCode
if tText = EMPTY then
  beep
  answer "No such code!"
  exit to top
end if
set itemdel to TAB
## Now you have the line and can extract all wanted columns from tText, 
## which will now only contain the one line in question
...
Best

Klaus

Re: Get row of data from datagrid bases on the name in Col 1.

Posted: Thu Feb 23, 2023 4:00 pm
by CAsba
Hi Klaus, Once again, many thanks - it worked perfectly...