chenging data in a text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a continuous form with text boxes with qty. To show a user a
percentage insted of qty on double click event I'm using the following:
Me.M1.Requery
If Me.FY > 0 Then
Me.M1 = Nz(Me.M1) / Me.FY
Else
Me.M1 = 0
End If
Me.M1.Format = "Percent"
Me.M1.Locked = True

The format is being changed into "Percent" for all form but the calculation
is done only for the selected row.

Is it necessary to make a loop and go through all of form's rows?
Could anybody advise anything?

Thanks
 
I'm using a continuous form with text boxes with qty. To show a user a
percentage insted of qty on double click event I'm using the following:

Would it not be better to use a query that does the conversion for you?

select m1, fy,
iif(fy>0, m1/fy, null) as pc
from mytable
etc.


and then put all three text boxes on the form. The alternative would be to
do the calculation in the controlsource of the textbox.

HTH


Tim F
 
The properties of a control apply to all instances of that control in a
continuous form. Your changes to the Value apply to the single current
record. You could change the ControlSource of the control, but I'd like to
suggest something different:

Instead of changing the data in a control, how about using two different
controls and swapping their visibility on a double-click.

Copy the M1 control and call it M1percent. Change its Visibility to False.
Lock it, Format it, and set the ControlSource to =IIF(FY > 0, M1/FY,
0)Lastly, copy the Left and Top properties from M1 and Format->SendToBack.

in M1's DoubleClick event:

M1percent.Visible = True
M1percent.SetFocus
M1.Visible = False

Similarly, in M1percent_DoubleClick

M1.Visible = True
M1.SetFocus
M1percent.Visible = False

A side benefit is that a text box's label will appear/disappear with it
automatically, so "qty" could alternate with "%"


HTH,

Kevin
 
Thanks a lot. It's a very good advise.

Kevin K. Sullivan said:
The properties of a control apply to all instances of that control in a
continuous form. Your changes to the Value apply to the single current
record. You could change the ControlSource of the control, but I'd like to
suggest something different:

Instead of changing the data in a control, how about using two different
controls and swapping their visibility on a double-click.

Copy the M1 control and call it M1percent. Change its Visibility to False.
Lock it, Format it, and set the ControlSource to =IIF(FY > 0, M1/FY,
0)Lastly, copy the Left and Top properties from M1 and Format->SendToBack.

in M1's DoubleClick event:

M1percent.Visible = True
M1percent.SetFocus
M1.Visible = False

Similarly, in M1percent_DoubleClick

M1.Visible = True
M1.SetFocus
M1percent.Visible = False

A side benefit is that a text box's label will appear/disappear with it
automatically, so "qty" could alternate with "%"


HTH,

Kevin
 
Back
Top