Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding to a value after clicking a button

Status
Not open for further replies.

Gazer44

Technical User
Mar 4, 2002
211
0
0
US
I have 2 forms open at the same time. One has a number field called 'score' which starts at 0. The other has buttons, when I click on 'buttonA' I want the 'score' to Add 1 and when click 'buttonB'-the score to minus 1.
Each form looks at seperate tables which are not linked.
Any help/ideas appreciated.
 
On Form where Buttons are at Create 2 command buttons

#1 Command button
Forms![FormName]![Score]= Forms![FormName]![Score]+1


#2 Command button
Forms![FormName]![Score]= Forms![FormName]![Score]-1

 
Thanks PMrider, this works OK but I've hit another slight prob.

I basically want to seperate the code below so that the first bit activates without the second and vice versa
(currently the two [score] lines of code activate when I only want either one or the other, depending if [answer] field = A or not)

How do I seperate them (I'm sure this is simple but just can't see it!)


Private Sub ButtonA_Click()
If Forms![form1]![Answer] = "A" Then Forms![form1]![TickA].Visible = True
Forms![form2]![Score] = Forms![form2]![Score] + 4


If Forms![form1]![Answer] <> &quot;A&quot; Then Forms![form1]![CrossA].Visible = True
Forms![form2]![Score] = Forms![form2]![Score] - 1

End Sub

cheers
 
Hi Gazer44,

Sorry it took so long to answer your question. I've been busy.

It looks like you are missing some code

Private Sub ButtonA_Click()
If Forms![form1]![Answer] = &quot;A&quot; Then
Forms![form1]![TickA].Visible = True
Forms![form2]![Score] = Forms![form2]![Score] + 4
ElseIf Forms![form1]![Answer] <> &quot;A&quot; Then
Forms![form1]![CrossA].Visible = True
Forms![form2]![Score] = Forms![form2]![Score] - 1
End If

End Sub

try this. Hope it works for you

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top