Button to change value in a field (1 Viewer)

ayjayh

Registered User.
Local time
Today, 23:23
Joined
Mar 29, 2002
Messages
20
I have a form to show values in from a table called Master. One of the fields in the table is called TSmin and contains integer values. I need to attach a macro or something to a button so that when I push the button TSmin increases by 1.
Sorry to be a Newbie here. All help welcome.
Tony
 

boblarson

Smeghead
Local time
Today, 15:23
Joined
Jan 12, 2001
Messages
32,059
Here's a bit of code to do the trick for you.

First, make sure that the text box that shows the TSmin value is named txtTSmin and not just TSmin.

Then, in Design view, do this. Select the button and in the properties window find the ON CLICK event. Then using the little dropdown list on it, select EVENT PROCEDURE and press the builder button that appears next to it.

When the code window opens up, you should be in something like this:

Private Sub TheButtonName_Click()

End Sub


So, paste this in between those lines:

' declares a variable to be used
Dim strTSmin as String
' adds 1 to the value of TSmin
strTSmin = txtTSmin.Value + 1
' sets the new value in place to the bound text box
txtTSmin.Value = strTSmin

BL
hth
 

ayjayh

Registered User.
Local time
Today, 23:23
Joined
Mar 29, 2002
Messages
20
Thanks Bob, it works a treat.
On a general point, I am trying to convert my original programs in dbase3 into Access and I think I need to learn VB (or is it VBA?). Can you suggest a good book or other source? Most stuff I read seems to stop short of this.
Tony
 

boblarson

Smeghead
Local time
Today, 15:23
Joined
Jan 12, 2001
Messages
32,059
I know that there are some good ones out there, but I haven't used any really. I started out learning VBA by learning VB (Microsoft VB Learning Edition Tutorial). Then I just used the help files, personal experimentation, this forum, and one book: Que Special Edition Using Microsoft Access 2000.

Maybe the others here have some better suggestions.

BL
hth
 

Users who are viewing this thread

Top Bottom