Selecting data from a Field with Variable Field Name

What I want to do is simply, from an active cell, select all records that have the same content as the active cell. For example I am in a filed call “State”, the content of that Field is “NY”, I want to have a procedure that when I click on it or execute it it selects all the fields that have “NY” in the “State” Field.

Panorama 6. Mac Pro late 2013, Sierra OS.

I have two local variables. The variables work fine, but my select statement does not work. It is driving me crazy. It should be so simple.

;Find same content in field
Local LFieldName,LFieldContent
LFieldName=info(“fieldname”)
LFieldContent=GRABDATA("",info(“fieldname”))
Select LFieldName=LFieldContent

Thanks guys.

George

What you are doing there is selecting all records where the content of the field equals the name of the field. There is a simple way to do this, using the fact that «» stands for the current field.

Local LFieldContent
LFieldContent = «»
Select «» = LFieldContent

The left chevron « is option-\ and the right chevron » is shift-option-\ on an American keyboard.

In the data sheet, you don’t necessarily have to write your own procedure to do this. Just control-click or right click the cell, and choose “Select Same Value” from the menu that appears.

If by chance he is in a different field when the selection actually takes place from when the variables were filled he could use the execute statement to handle things.

execute {Select }+LFieldName+{="}+LFieldContent+{"}

This assumes you are selecting from a text field. If not, you would eliminate the quotes around the LFieldContent variable.

Thanks Partner.

Works like a charm. And fast.

Best Regards,

George

Thanks Gary.

Another way to skin the cat.

Regards,

George