Control Button

  • Thread starter Thread starter Wes Derhak
  • Start date Start date
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
 
Private Sub YourCommandButton_Click()
YourTextBox = YourTextBox + 1
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
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.
 
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
 
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
 

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

Back
Top