Whats the Differnce

D

DS

I have an Unbound Textbox. On the Textbox's afterUpdate I have code
that formats the number into a currency format, if I enter a number from
my computer keyboard and leave the field the number turns into currency.

If I input a set of numbers from a keypad into the field and leave the
field nothing happens. The numbers remain the same.
I tried from the keypad both of these options.
Me.Textbox1 = 1
Me.Textbox1 = "1"
Whats the difference between a keyboard number and an onscreen number?
Do I need to use another event other than afterupdate for this?
Thanks
DS
 
D

DS

DS said:
I have an Unbound Textbox. On the Textbox's afterUpdate I have code
that formats the number into a currency format, if I enter a number from
my computer keyboard and leave the field the number turns into currency.

If I input a set of numbers from a keypad into the field and leave the
field nothing happens. The numbers remain the same.
I tried from the keypad both of these options.
Me.Textbox1 = 1
Me.Textbox1 = "1"
Whats the difference between a keyboard number and an onscreen number?
Do I need to use another event other than afterupdate for this?
Thanks
DS
Here's some more info...I just tried this and I get a runtime error#5
it stops at the strx line....

Private Sub Command18_Click()
Dim strX As String
Me.TxtDecimal = Me.TxtDecimal & 1
strX = Left(TxtDecimal.Value, Len(Trim(TxtDecimal.Value)) - 2) &
"." & right(TxtDecimal.Value, 2)
TxtDecimal.Value = Format(strX, "$0.00")
End Sub
 
D

DS

DS said:
I have an Unbound Textbox. On the Textbox's afterUpdate I have code
that formats the number into a currency format, if I enter a number from
my computer keyboard and leave the field the number turns into currency.

If I input a set of numbers from a keypad into the field and leave the
field nothing happens. The numbers remain the same.
I tried from the keypad both of these options.
Me.Textbox1 = 1
Me.Textbox1 = "1"
Whats the difference between a keyboard number and an onscreen number?
Do I need to use another event other than afterupdate for this?
Thanks
DS
Heres some more Info...I just tried this and I get a Runtime Error#5
It stops at the strx line..
Private Sub Command18_Click()
Dim strX As String
Me.TxtDecimal = Me.TxtDecimal & 1
strX = Left(TxtDecimal.Value, Len(Trim(TxtDecimal.Value)) - 2) &
"." & right(TxtDecimal.Value, 2)
TxtDecimal.Value = Format(strX, "$0.00")
End Sub
 
R

RoyVidar

DS wrote in message said:
I have an Unbound Textbox. On the Textbox's afterUpdate I have code that
formats the number into a currency format, if I enter a number from my
computer keyboard and leave the field the number turns into currency.

If I input a set of numbers from a keypad into the field and leave the field
nothing happens. The numbers remain the same.
I tried from the keypad both of these options.
Me.Textbox1 = 1
Me.Textbox1 = "1"
Whats the difference between a keyboard number and an onscreen number?
Do I need to use another event other than afterupdate for this?
Thanks
DS

I think the after update event of controls usually only fire after
entering
keystrokes through the keyboard prior to leaving it.

For Access to react upon entering characters from other sources than
the
keyboard, I think one could try the following, set focus to the control
in
question, and assign values to it's .Text property, i e

Me!Textbox1.setfocus
Me!Textbox1.text = 1
' to make the after update fire
Me!txtSomeOtherControl.setfocus

Which I think should fire the after update when leaving the control,
else,
why not just fire off/call the sub doing the formatting stuff directly
after entering
the number?
 
R

Rick Brandt

DS said:
I have an Unbound Textbox. On the Textbox's afterUpdate I have code
that formats the number into a currency format, if I enter a number
from my computer keyboard and leave the field the number turns into

Have you tried simply setting the format property of the TextBox? You should
not need code just to change appearance.
 
A

Albert D.Kallal

If I input a set of numbers from a keypad into the field and leave the
field nothing happens.

What keypad? You mean the one on the right side of your keyboard? I don't
see why using the top row vs the keypad should make any difference.

Remember, if you use code to modify a control on a screen, that controls
events don't fire

(it would quite nasty if you needed to use code to modify some values of a
control, and all the events for the control would execute (they do NOT).

However, if you do modify a control via code, and want the after update
event to fire..then you can just call the code.

Call "name of after update event code goes here"

You can also capture, and "deal with" values BEFORE the update events, and
for that you use the on-change event.

Note that when you use the on change event, then you need to use the
me.MyContorlName.Text (the text property), as the "value" has not yet been
changed. The ".text" property is ONLY available when the control has the
focus..but you can do keystroke processing on the control by using on
change...

As a few others have mentioned, I have no idea why you are not using regular
formatting for this control....
 
D

DS

RoyVidar said:
I think the after update event of controls usually only fire after entering
keystrokes through the keyboard prior to leaving it.

For Access to react upon entering characters from other sources than the
keyboard, I think one could try the following, set focus to the control in
question, and assign values to it's .Text property, i e

Me!Textbox1.setfocus
Me!Textbox1.text = 1
' to make the after update fire
Me!txtSomeOtherControl.setfocus

Which I think should fire the after update when leaving the control, else,
why not just fire off/call the sub doing the formatting stuff directly
after entering
the number?
The second suggestion sounds good, but how would I do that?
Thanks
DS
 
D

DS

Albert said:
field nothing happens.

What keypad? You mean the one on the right side of your keyboard? I don't
see why using the top row vs the keypad should make any difference.

Remember, if you use code to modify a control on a screen, that controls
events don't fire

(it would quite nasty if you needed to use code to modify some values of a
control, and all the events for the control would execute (they do NOT).

However, if you do modify a control via code, and want the after update
event to fire..then you can just call the code.

Call "name of after update event code goes here"

You can also capture, and "deal with" values BEFORE the update events, and
for that you use the on-change event.

Note that when you use the on change event, then you need to use the
me.MyContorlName.Text (the text property), as the "value" has not yet been
changed. The ".text" property is ONLY available when the control has the
focus..but you can do keystroke processing on the control by using on
change...

As a few others have mentioned, I have no idea why you are not using regular
formatting for this control....
Well I tried regular formating. I need to have the field show $0.00
The main problem is that there will be no keyboard attached to the
computer, the numbers will be entered using an on screen pad via a
touchscreen. The other criteria is that the on screen keypad doesn't
have a decimal key on it. So the delima is how do I enter currency
using this keypad into a bond textfield?
Thanks
DS
 
D

DS

Rick said:
Have you tried simply setting the format property of the TextBox? You should
not need code just to change appearance.
Hi Rick, see my post to Albert> I tries the format thing but it just
doesn't work for the application I need, unless I'm missing something here.
Thanks
DS
 
R

Rick Brandt

DS said:
Hi Rick, see my post to Albert> I tries the format thing but it just
doesn't work for the application I need, unless I'm missing something
here. Thanks
DS

What entry in the format property did you use?
 
D

DS

Rick said:
In the property you don't use the function. Just enter $0.00.
This works. I have a hidden textbox which holds the value and a label
to display it. This comes from 10 command buttons 1 to 0,
Private Sub Command3_Click()
Me.TxtHidden = Me.TxtHidden & 1
Dim strX As String

'get length of hidden boxes text
'and adjust output accordingly
Select Case Len(Trim(TxtHidden.Value))
Case 0
strX = "0"
Case 1
strX = ".0" & TxtHidden.Value
Case 2
strX = "." & TxtHidden.Value
Case Else
strX = Left(TxtHidden.Value, Len(Trim(TxtHidden.Value)) -
2) & "." & right(TxtHidden.Value, 2)
End Select

'display formatted result in label
LblDisplay.Caption = Format(strX, "$0.00")
End Sub

So now I have an onscreen keypad to enter currency without entering a
decimal point!

Thanks Everyone!
DS
 
A

Albert D.Kallal

Well I tried regular formating. I need to have the field show $0.00 The
main problem is that there will be no keyboard attached to the computer,
the numbers will be entered using an on screen pad via a touchscreen. The
other criteria is that the on screen keypad doesn't have a decimal key on
it. So the delima is how do I enter currency using this keypad into a
bond textfield?

Ok, with this "on screen" keypad, does not the user have to hit enter, or
ok, or somthing? (how will you know the user is done?).

You need to answer the above queastion.

While you are answering the above question, lets get you general soltion to
for the decimal poiint deal. (fact is, you don't want to write code for
*every* contl on that screen that needs numbers.

So, in a public module, we can put our code to be used for ALL number
contorls

Public Sub AddDecimal(c as control)


Dim strValue As String


If IsNull(c.Value) = True Then
Exit Function
End If


' convert number to string


strValue = CStr(c)


If InStr(strValue, ".") = 0 Then
' add the decimal
c.Value = c.Value / 100
End If


End Sub


Now, for each number type contorl on a form, simply call the above code in
the after update event



Call AddDecimal(me.SalesAmount)

I have to assume there is some type of "ok", or "enter" button you use with
this keypad. Likely, this "enter" key does a tab, or whatever, and *should*
trigger the after update. If the focus moves from the field each time you
enter a number on the keypad, then you can't use the after update event, as
it will fire each time, and you need a different approach. (and, if that is
the case, then my above suggestion to use after update will not work). So,
the only thing that remains here is how the user does a "enter" (if they use
the touch screen to "move" to the next field, then after update likely does
fire).
 
D

DS

Albert said:
Ok, with this "on screen" keypad, does not the user have to hit enter, or
ok, or somthing? (how will you know the user is done?).

You need to answer the above queastion.

While you are answering the above question, lets get you general soltion to
for the decimal poiint deal. (fact is, you don't want to write code for
*every* contl on that screen that needs numbers.

So, in a public module, we can put our code to be used for ALL number
contorls

Public Sub AddDecimal(c as control)


Dim strValue As String


If IsNull(c.Value) = True Then
Exit Function
End If


' convert number to string


strValue = CStr(c)


If InStr(strValue, ".") = 0 Then
' add the decimal
c.Value = c.Value / 100
End If


End Sub


Now, for each number type contorl on a form, simply call the above code in
the after update event



Call AddDecimal(me.SalesAmount)

I have to assume there is some type of "ok", or "enter" button you use with
this keypad. Likely, this "enter" key does a tab, or whatever, and *should*
trigger the after update. If the focus moves from the field each time you
enter a number on the keypad, then you can't use the after update event, as
it will fire each time, and you need a different approach. (and, if that is
the case, then my above suggestion to use after update will not work). So,
the only thing that remains here is how the user does a "enter" (if they use
the touch screen to "move" to the next field, then after update likely does
fire).
There is an Enter button. So basically as they are putting the numbers
in they see the input in the label. Albert see my previous message. I
put that code on each command button. The input goes into a hidden text
field and is displayed on a label....you hit Enter to finalize the
procedjure and drop the number into the bound field of another form. It
works quite well!
Thank You for your input!
As always much appreciated and respected!
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top