I want to modify a UDF I have to use any type variable to open a form, set the index and optionally locate a record if one is specified, else use the default index as record number order and open the form to the last record.
I defined my parameter as 'arec = null_value() as A' - which works great until I want to use a numeric value.
Since this is an optional parameter, how would I test if arec was set to a numeric value or not since isnull() will throw an error for type N?
Here's my script:
I use a primary key for a table that is auto increment and padded with leading 0's. And I have an index that converts this key into a number so the user doesn't have to enter the 0's when searching. Now I want to be able to call another form for this table from a button using the number the user enters. In this scenario the called form is using a report preview supercontrol to open an interactive report for the selected record - without applying a query to the form.
If I use the primary key & index instead, it defeats the effect I am trying to achieve & screws up what the supercontrol and report are set to do using the numeric field.
I defined my parameter as 'arec = null_value() as A' - which works great until I want to use a numeric value.
Since this is an optional parameter, how would I test if arec was set to a numeric value or not since isnull() will throw an error for type N?
Here's my script:
Code:
FUNCTION Go_Frm as L(layoutname as C,Index_Name as C,arec = null_value() as A) 'Description: open/switch to form at specified record set by local var 'set arec according to indexed field type DIM frm as P DIM vType as c [COLOR=#0000ff]vType = typeof(arec) 'this should be helpful - how to use?[/COLOR] frm = obj(layoutname) IF .not. is_object(frm) THEN frm = :form.load(layoutname) END IF [COLOR=#ff0000]IF .not. isnull(arec) THEN [/COLOR][COLOR=#0000ff]'errs if numeric value entered[/COLOR][COLOR=#ff0000][/COLOR] IF Index_Name <> "" THEN frm.index_setexplicit(Index_Name) tln("Layout",layoutname) tln("Index",Index_Name) frm.find(arec) ELSE 'use record number order frm.index_set("") frm.fetch_last() END IF ELSE frm.fetch_last() END IF frm.show() frm.activate() Go_frm=.t. END FUNCTION
If I use the primary key & index instead, it defeats the effect I am trying to achieve & screws up what the supercontrol and report are set to do using the numeric field.
Comment