Control Button

W

Wes Derhak

Hello

I need some help with a form. What I am trying to do is, to place a button
on a form in MS Access so that when you click on it, in another field it
will display a number one. If you click on the same button again it will
change the one to a two and so on.

Wes
 
M

missinglinq via AccessMonster.com

Private Sub YourCommandButton_Click()
YourTextBox = YourTextBox + 1
End Sub
 
E

Ed Metcalfe

Wes Derhak said:
Hello

I need some help with a form. What I am trying to do is, to place a button
on a form in MS Access so that when you click on it, in another field it
will display a number one. If you click on the same button again it will
change the one to a two and so on.

Wes

You'll need to change the button and textbox names as appropriate:

Private Sub cmdIncrement_Click()
If Not IsNull(Me.txtSomeField.Value) Then
Me.txtSomeField.Value = Me.txtSomeField.Value + 1
Else
Me.txtSomeField.Value = 1
End If
End Sub

Ed Metcalfe.
 
G

Graham R Seach

Hi Wes,

The following will work whether the textbox is bound or unbound. Change
"cmdAdd" to the name of your button, and change "txtTextBox" to the name of
your textbox.

Private Sub cmdAdd_Click()
Me!txtTextBox = (Me!txtTextBox, 0) + 1
End Sub


Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Graham R Seach

Oops, sorry, I pressed the keys but the two most important characters went
missing:

Private Sub cmdAdd_Click()
Me!txtTextBox = Nz(Me!txtTextBox, 0) + 1
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Top