I needed to add a right clcik menu item that would search for a character string anywhere in a field. This was very straightforward on a form, but a bit more of a challenge on a browse - so I thought I would share the code. It may not handle every situation, but it does what I needed, and remember it is free. :-)
The issue here is that the search is on a 1-1 child field. If you use action scripting to get you going, "<Cross Level>" will be used as a parameter in the query. This works on a form, but not a browse. On a browse you get errors. But remember, Cross Level is required for a query on a 1-many child.
This code does not run the cross level query if it is a set, but you can easily add that IF statement.
My way of getting the set name for the browse seems cumbersome, in case someone knows a better way.
Bill.
Code:
'for right click menu on a layout, "field contains the characters" f = topparent.this field_object_name = f.active_drilldown() table_fieldname = eval(field_object_name +".entry.name") search_for = ui_get_text("Filter Field:" +table_fieldname,"Search for:") if search_for = "" END end if tParent = f.table_get() parent_tablename = tParent.name_get() vFilter_string = quote(search_for) +"$" +table_fieldname ' e.g. "tom"$Eecore->first_name if f.class() = "browse" ' because browse does not honor the parameter in queryrun() v = this.dictionary_get() if file.filename_parse(v, "e") = ".set" set_table_name = file.filename_parse(v,"ne") else set_table_name = parent_tablename end if records_found = a5_get_records_in_query(set_table_name,vFilter_string) if records_found <= 0 ui_msg_box("Notice", "No records in query",UI_STOP_SYMBOL) END end if end if 'f.queryrun(vFilter_string,"recno()","","No","<Cross Level>",.t.) f.queryrun(vFilter_string,"recno()","","No",parent_tablename,.t.) if f.class() = "browse" f.browse_refresh() ' refresh did not always work, not needed for form end if
This code does not run the cross level query if it is a set, but you can easily add that IF statement.
My way of getting the set name for the browse seems cumbersome, in case someone knows a better way.
Bill.