Using selection in one database to select items in a second database

Database One has a list of item numbers.

Database Two has the same item numbers with “TB-” as a prefix

How do I write a procedure to select items in DB 2 based on the
currently selected items in DB 1?

So for example, DB 1 shows:

11-401
11-402

and DB 2 shows:

TB-11-1
TB-11-2
TB-11-401
TB-11-402
TB-11-403
etc.

Is there a way to select the items in DB 2 which contain the same item
numbers as are currently selected in DB 1? So after the routine, DB 2
would display:

TB-11-401
TB-11-402

If I were searching I would use “contains” since I know there are matches between the two DBs. Is there a way to do this with a selection formula?

thanks,
bk

If DB 2 is the active database, you could do something like this

Local x
ArraySelectedBuild x,¶,"DB 1","-"+FieldName
Select x contains ThisField["-",-1]

The ArraySelectedBuild builds an array from the selected records in DB 1. It places a hyphen in front of each element, to mark its beginning, in case the first number should ever happen to have a single digit.

ThisField["-",-1] strips off everything before the first hyphen and looks to see if that is contained in the array.

You would replace FieldName and ThisField with the actual field names in DB 1 and DB 2 respectively.

Dave

2 posts were split to a new topic: How do you tell whether a text file is using carriage returns or line feeds