One more update I had still left reference to non existing
INDEX values in my correction. Also forgot Access requires
focus shift back to textbox before changing it. ( and Marshall
is correct that it's better to use Textbox than lable.
You'll have 10 buttons with distinct names and events
Sub cmdCalcNumButton0_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "0"
End Sub
Sub cmdCalcNumButton1_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "1"
End Sub
Sub cmdCalcNumButton2_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "2"
End Sub
Sub cmdCalcNumButton3_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "3"
End Sub
Sub cmdCalcNumButton4_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "4"
End Sub
Sub cmdCalcNumButton5_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "5"
End Sub
Sub cmdCalcNumButton6_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "6"
End Sub
Sub cmdCalcNumButton7_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "7"
End Sub
Sub cmdCalcNumButton8_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "8"
End Sub
Sub cmdCalcNumButton9_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = lblCalcValue.Text & "9"
End Sub
' and here we can add in the code for a clear button and
a back button
Sub cmdCalcBackButton_Click()
lblCalcValue.SetFocus
If Len(lblCalcValue.Text) > 0 then
lblCalcValue.Text = Left(lblCalcValue.Text,
Len(lblCalcValue.Text) - 1)
End If
End Sub
Sub cmdCalcClearButton_Click()
lblCalcValue.SetFocus
lblCalcValue.Text = ""
End Sub
Note that I have attached an Access MDB with a working sample on the
form.
I hope this is helpful to you.
PS - think of us for any future need
of Active X components,
or programming services
Jeff Bennett
(e-mail address removed)
* Bennet-Tec Information Systems, Inc
* 50 Jericho Tpk, Jericho, NY 11753
* Phone 516 997 5596, Fax - 5597
* RELIABLE Components Make You Look Sharp!
* TList/Pro * ALLText HT/Pro * MetaDraw *
* Custom Software Development Services Too.
*
WWW.Bennet-Tec.Com
=================== ===================