click to add to the value in a textbox

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

Guest

I want to be able to click a text box and have it add .5 each time I click it . I've got about 40 boxes and would like to not recode for each textbox. Any ideas?
 
Hi Dave

Something like this. In your form module:

Private Function AddPointFive()
With Me.ActiveControl
.Value = Nz(.Value,0) + 0.5
End With
End Function

Then set the OnClick property for each of your textboxes to:
=AddPointFive()

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


dave said:
I want to be able to click a text box and have it add .5 each time I click
it . I've got about 40 boxes and would like to not recode for each textbox.
Any ideas?
 
Add the following function to a module:

Function IncrementTextBox()
Dim ctlCurr As Control

Set ctlCurr = Screen.ActiveControl
If TypeOf ctlCurr Is TextBox Then
If Not IsNull(ctlCurr) Then
If IsNumeric(ctlCurr) Then
ctlCurr = ctlCurr + 0.5
End If
End If
End If

End Function

Set the On Click event for all of your text boxes to =IncrementTextBox()

(make sure you include both the = sign and the () at the end)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



dave said:
I want to be able to click a text box and have it add .5 each time I click
it . I've got about 40 boxes and would like to not recode for each textbox.
Any ideas?
 
Back
Top