I want to program a button on a form that contains a browse. The form is based on a single table so I shouldn't need a cursor.
The button should change the value in the field that the user is currently in, to the value of a character variable VAR->VarChar4 and then move to the next record and do the same thing.
The code below is where I am now... it works (sort of) insofar as it changes a specified field ()... but I want it to change the contents of the field that the user is currently in:
:frmhairresultsinspect:tables:hair6_sc.sb = VAR->VarChar4 'hair6_sc.sb is my problem ... I want to change the field that the user is currently in... not hair6_sc.sb
How can I get the fieldname of the current field and place it in this line?
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=Recordsselected.value > 30",local_variables()) THEN
'Displays a message box (style:'OK Button', image: 'Stop symbol', id: 'CannotDo').
DIM SHARED CannotDo_result as N
DIM SHARED CannotDo_OK_Button as L
CannotDo_OK_Button = .F.
title_var = "YOU CANNOT CHANGE THE RESULTS FOR MORE THAN 30 SAMPLES!!!"
message_text_var = <<%text%
YOU CANNOT CHANGE THE RESULTS FOR MORE THAN 30 SAMPLES!!!
Please use the Query Genie to select a smaller set of records.
%text%
CannotDo_result=ui_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_STOP_SYMBOL)
'Test to see which button on the message box was pressed....
SELECT
CASE CannotDo_result = UI_OK_SELECTED
CannotDo_OK_Button= .t.
END SELECT
END IF
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=Recordsselected.value > 30",local_variables()) THEN
'End the current script
END
END IF
'Insert label into script: 'NextRecord'.
NEXTRECORD:
'Allow editing of records in current form at parent level.
topparent.allow_change(.t.)
:FrmHairResultsInspect.allow_change(.F.)
:FrmHairResultsInspect:CONTROL_BROWSE1.allow_change(.T.)
:FrmHairResultsInspect:Tables:hair6_sc.change_begin(HONOR_FIELD_RULES)
:frmhairresultsinspect:tables:hair6_sc.sb = VAR->VarChar4 'hair6_sc.sb is my problem ... I want to change the field that the user is currently in
:FrmHairResultsInspect:Tables:hair6_sc.change_end(.t.)
'Save record in current form at parent level.
topparent.commit()
'Go to next record in current form at parent level.
topparent.fetch_next()
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=.not. eof()",local_variables()) THEN
'If condition '.NOT. eof()' is True, then jump to label in script: 'NextRecord'.
'The a5_eval_expression() function evaluates the expression in the context of the currently open form.
'This allows you to use field names from the form's tables in the expression.
if a5_eval_expression("=.NOT. eof()") then
GOTO NEXTRECORD
end if
END IF
The button should change the value in the field that the user is currently in, to the value of a character variable VAR->VarChar4 and then move to the next record and do the same thing.
The code below is where I am now... it works (sort of) insofar as it changes a specified field ()... but I want it to change the contents of the field that the user is currently in:
:frmhairresultsinspect:tables:hair6_sc.sb = VAR->VarChar4 'hair6_sc.sb is my problem ... I want to change the field that the user is currently in... not hair6_sc.sb
How can I get the fieldname of the current field and place it in this line?
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=Recordsselected.value > 30",local_variables()) THEN
'Displays a message box (style:'OK Button', image: 'Stop symbol', id: 'CannotDo').
DIM SHARED CannotDo_result as N
DIM SHARED CannotDo_OK_Button as L
CannotDo_OK_Button = .F.
title_var = "YOU CANNOT CHANGE THE RESULTS FOR MORE THAN 30 SAMPLES!!!"
message_text_var = <<%text%
YOU CANNOT CHANGE THE RESULTS FOR MORE THAN 30 SAMPLES!!!
Please use the Query Genie to select a smaller set of records.
%text%
CannotDo_result=ui_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_STOP_SYMBOL)
'Test to see which button on the message box was pressed....
SELECT
CASE CannotDo_result = UI_OK_SELECTED
CannotDo_OK_Button= .t.
END SELECT
END IF
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=Recordsselected.value > 30",local_variables()) THEN
'End the current script
END
END IF
'Insert label into script: 'NextRecord'.
NEXTRECORD:
'Allow editing of records in current form at parent level.
topparent.allow_change(.t.)
:FrmHairResultsInspect.allow_change(.F.)
:FrmHairResultsInspect:CONTROL_BROWSE1.allow_change(.T.)
:FrmHairResultsInspect:Tables:hair6_sc.change_begin(HONOR_FIELD_RULES)
:frmhairresultsinspect:tables:hair6_sc.sb = VAR->VarChar4 'hair6_sc.sb is my problem ... I want to change the field that the user is currently in
:FrmHairResultsInspect:Tables:hair6_sc.change_end(.t.)
'Save record in current form at parent level.
topparent.commit()
'Go to next record in current form at parent level.
topparent.fetch_next()
'Conditional code follows. Executes only if the condition expression is True.
IF a5_eval_expression("=.not. eof()",local_variables()) THEN
'If condition '.NOT. eof()' is True, then jump to label in script: 'NextRecord'.
'The a5_eval_expression() function evaluates the expression in the context of the currently open form.
'This allows you to use field names from the form's tables in the expression.
if a5_eval_expression("=.NOT. eof()") then
GOTO NEXTRECORD
end if
END IF
Comment