Discussion:
Setting focus on Controls/ the Activate function
(too old to reply)
Matt Lovinger
2005-02-03 20:49:29 UTC
Permalink
Hi All,
I have a form in which I want to control user action very closely. There are several ways that the transaction can fail, and I want to set controls to their original state (including focus) after each attempt,whether or not they are successful.
.
The C/SIDE help indicates that there is a function "ACTIVATE" that will set the focus to a particular control or form. I have tried this syntax= 'CurrForm.ControlName.ACTIVATE' . This command seems to have no effect, or at least an erratic effect.

I checked the C/SIDE help a little closer and found this:
When you call this function on a control, the system makes the control the active control on the form. If the control is already active, the system gives focus to the control. If the control is not active, the system gives it focus the next time the form is activated. You must load the form before you can activate its controls.

I tried to call ACTIVATE twice in a row (Once to make the control active, then again to set the focus). Again, no discernable effect. Is there another method I can use to set the focus to a control immediately?

Matt Lovinger
Hamilton Aerospace Technology
Savatage99
2005-02-04 17:45:02 UTC
Permalink
Maybe you could explain the form a little better. There might be other ways
to accomplish your goal.
Post by Matt Lovinger
Hi All,
I have a form in which I want to control user action very closely. There are several ways that the transaction can fail, and I want to set controls to their original state (including focus) after each attempt,whether or not they are successful.
..
The C/SIDE help indicates that there is a function "ACTIVATE" that will set the focus to a particular control or form. I have tried this syntax= 'CurrForm.ControlName.ACTIVATE' . This command seems to have no effect, or at least an erratic effect.
When you call this function on a control, the system makes the control the active control on the form. If the control is already active, the system gives focus to the control. If the control is not active, the system gives it focus the next time the form is activated. You must load the form before you can activate its controls.
I tried to call ACTIVATE twice in a row (Once to make the control active, then again to set the focus). Again, no discernable effect. Is there another method I can use to set the focus to a control immediately?
Matt Lovinger
Hamilton Aerospace Technology
Matt Lovinger
2005-02-07 18:55:27 UTC
Permalink
Ok,
Here goes, we have implemented a barcoding solution for time entry, but in
order to maximize throughput, we want to allow the users to simply swipe
their badges followed by a task card with the task nmber printed on it. The
barcode reader is programmed to add a CR/LF after we read. This allows us
to use the OnValidate trigger of the Task Number text box in place of the OK
button that was present on the form in the past. There are a number of
error conditions that we need to check for before entering the data in the
database. In addition there is a Punch out button that the users push when
they clock out for the day. What we want is to be able to set the active
control to the employee number text box in all cases where the action has
been completed successfully, and to set it to the taskcode text box if there
has been an error entering the taskcode. Is there a way to accomplish this
in Navision?

Matt Lovinger
Hamilton Aerospace Technology
Post by Savatage99
Maybe you could explain the form a little better. There might be other ways
to accomplish your goal.
Post by Matt Lovinger
Hi All,
I have a form in which I want to control user action very closely.
There are several ways that the transaction can fail, and I want to set
controls to their original state (including focus) after each
attempt,whether or not they are successful.
Post by Savatage99
Post by Matt Lovinger
..
The C/SIDE help indicates that there is a function "ACTIVATE" that will
set the focus to a particular control or form. I have tried this syntax=
'CurrForm.ControlName.ACTIVATE' . This command seems to have no effect, or
at least an erratic effect.
Post by Savatage99
Post by Matt Lovinger
When you call this function on a control, the system makes the control
the active control on the form. If the control is already active, the system
gives focus to the control. If the control is not active, the system gives
it focus the next time the form is activated. You must load the form before
you can activate its controls.
Post by Savatage99
Post by Matt Lovinger
I tried to call ACTIVATE twice in a row (Once to make the control
active, then again to set the focus). Again, no discernable effect. Is
there another method I can use to set the focus to a control immediately?
Post by Savatage99
Post by Matt Lovinger
Matt Lovinger
Hamilton Aerospace Technology
John Nozzi [MSFT]
2005-02-11 22:01:40 UTC
Permalink
The only way to make sure that a certain control is activated on a form is
to have that control be a field in the Primary Key for the table underneath
the form, and to insert a new record. The way to force the insert of a new
record is to have the form open to an empty table (as least empty in regards
to the current filter set).

I suggest that you create a separate table for the function, with the form
associated with that table. The primary key of this table should be the
user badge number (whatever gets swiped first). Once the data entry is
complete, the data should be processed into another table or set of tables,
and the record inserted in this special table should be deleted. If the
processing must be canceled for any reason after the record is created, it
should also be deleted. Thus, the user is always looking at an empty table,
which puts the form in insert mode, which forces the correct control to be
activated. From there on, the "NextControl" property on each control ought
to direct the focus OK.

This also has a nice side effect, in that the rest of the controls can be
initialized to whatever default values you want, either using the InitValue
properties on the fields, or the OnNewRecord trigger on the form, or the
OnInsert trigger in the table, depending on the timing of when you want the
controls initialized.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

John Nozzi [MSFT]
____________________________
Post by Matt Lovinger
Ok,
Here goes, we have implemented a barcoding solution for time entry, but in
order to maximize throughput, we want to allow the users to simply swipe
their badges followed by a task card with the task nmber printed on it.
The
barcode reader is programmed to add a CR/LF after we read. This allows us
to use the OnValidate trigger of the Task Number text box in place of the OK
button that was present on the form in the past. There are a number of
error conditions that we need to check for before entering the data in the
database. In addition there is a Punch out button that the users push when
they clock out for the day. What we want is to be able to set the active
control to the employee number text box in all cases where the action has
been completed successfully, and to set it to the taskcode text box if there
has been an error entering the taskcode. Is there a way to accomplish this
in Navision?
Matt Lovinger
Hamilton Aerospace Technology
Post by Savatage99
Maybe you could explain the form a little better. There might be other
ways
Post by Savatage99
to accomplish your goal.
Post by Matt Lovinger
Hi All,
I have a form in which I want to control user action very closely.
There are several ways that the transaction can fail, and I want to set
controls to their original state (including focus) after each
attempt,whether or not they are successful.
Post by Savatage99
Post by Matt Lovinger
..
The C/SIDE help indicates that there is a function "ACTIVATE" that will
set the focus to a particular control or form. I have tried this syntax=
'CurrForm.ControlName.ACTIVATE' . This command seems to have no effect, or
at least an erratic effect.
Post by Savatage99
Post by Matt Lovinger
When you call this function on a control, the system makes the control
the active control on the form. If the control is already active, the system
gives focus to the control. If the control is not active, the system gives
it focus the next time the form is activated. You must load the form before
you can activate its controls.
Post by Savatage99
Post by Matt Lovinger
I tried to call ACTIVATE twice in a row (Once to make the control
active, then again to set the focus). Again, no discernable effect. Is
there another method I can use to set the focus to a control immediately?
Post by Savatage99
Post by Matt Lovinger
Matt Lovinger
Hamilton Aerospace Technology
Matt Lovinger
2005-02-11 22:51:54 UTC
Permalink
The infrastructure is already taken care of, it works fine. What I need is
control over the form. Luc van Dyck's suggestion about using an automation
object seemed pretty sound. Trouble is that I do not know how to define the
WScript object that he describes. I also know that using the validate
trigger to initiate the write operation is not an optimal solution to my
problem either, but my instructions are to acomplish the task without
requiring the user to press a button or the enter key.

Matt Lovinger
Hamilton Aerospace Technologies
Post by John Nozzi [MSFT]
The only way to make sure that a certain control is activated on a form is
to have that control be a field in the Primary Key for the table underneath
the form, and to insert a new record. The way to force the insert of a new
record is to have the form open to an empty table (as least empty in regards
to the current filter set).
I suggest that you create a separate table for the function, with the form
associated with that table. The primary key of this table should be the
user badge number (whatever gets swiped first). Once the data entry is
complete, the data should be processed into another table or set of tables,
and the record inserted in this special table should be deleted. If the
processing must be canceled for any reason after the record is created, it
should also be deleted. Thus, the user is always looking at an empty table,
which puts the form in insert mode, which forces the correct control to be
activated. From there on, the "NextControl" property on each control ought
to direct the focus OK.
This also has a nice side effect, in that the rest of the controls can be
initialized to whatever default values you want, either using the InitValue
properties on the fields, or the OnNewRecord trigger on the form, or the
OnInsert trigger in the table, depending on the timing of when you want the
controls initialized.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
John Nozzi [MSFT]
____________________________
Post by Matt Lovinger
Ok,
Here goes, we have implemented a barcoding solution for time entry, but in
order to maximize throughput, we want to allow the users to simply swipe
their badges followed by a task card with the task nmber printed on it.
The
barcode reader is programmed to add a CR/LF after we read. This allows us
to use the OnValidate trigger of the Task Number text box in place of
the
Post by John Nozzi [MSFT]
Post by Matt Lovinger
OK
button that was present on the form in the past. There are a number of
error conditions that we need to check for before entering the data in the
database. In addition there is a Punch out button that the users push when
they clock out for the day. What we want is to be able to set the active
control to the employee number text box in all cases where the action has
been completed successfully, and to set it to the taskcode text box if there
has been an error entering the taskcode. Is there a way to accomplish this
in Navision?
Matt Lovinger
Hamilton Aerospace Technology
Post by Savatage99
Maybe you could explain the form a little better. There might be other
ways
Post by Savatage99
to accomplish your goal.
Post by Matt Lovinger
Hi All,
I have a form in which I want to control user action very closely.
There are several ways that the transaction can fail, and I want to set
controls to their original state (including focus) after each
attempt,whether or not they are successful.
Post by Savatage99
Post by Matt Lovinger
..
The C/SIDE help indicates that there is a function "ACTIVATE" that will
set the focus to a particular control or form. I have tried this syntax=
'CurrForm.ControlName.ACTIVATE' . This command seems to have no effect, or
at least an erratic effect.
Post by Savatage99
Post by Matt Lovinger
When you call this function on a control, the system makes the control
the active control on the form. If the control is already active, the system
gives focus to the control. If the control is not active, the system gives
it focus the next time the form is activated. You must load the form before
you can activate its controls.
Post by Savatage99
Post by Matt Lovinger
I tried to call ACTIVATE twice in a row (Once to make the control
active, then again to set the focus). Again, no discernable effect.
Is
Post by John Nozzi [MSFT]
Post by Matt Lovinger
there another method I can use to set the focus to a control
immediately?
Post by John Nozzi [MSFT]
Post by Matt Lovinger
Post by Savatage99
Post by Matt Lovinger
Matt Lovinger
Hamilton Aerospace Technology
Loading...