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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counter on form

Status
Not open for further replies.

fishtek

Technical User
Aug 21, 2002
56
US
I have a form that I want serve as a count sheet for organisms. On the form I have text boxes that hold counts for various critters. I would like to place a button on the form that increases the count in the active text box by 1 for each click. (Initially the text box would be null) I have made this work with a macro in Excel but have no idea where to start in Access. Thanks for any help..
 


Me.critters = Me.critters + 1

should work

you may also want to deal with the null value
If Len(Me.critters) > 0 Then

Me.critters = Me.critters + 1
Else

Me.critters = 1

End If




Hope this helps

Jimmy
 
Thanks for your response ClydeData. How do I use the code if I have multiple textboxes on the form but only want the count to increase on the active one. Thanks again..
 
If you have a command button besite each txt box the just use the name of the textbox in the control




Me.YourTextBox = Me.YourTextBox + 1


Hope this helps

Jimmy
 
How are ya fishtek . . .

In the [blue]Tag[/blue] property of the organism controls, enter a question mark [blue]?[/blue] (no quotations please!). Then in your button try:
Code:
[blue]   Dim ctlName As String
   
   ctlName = Screen.ActiveControl.Name
   
   If Me(ctlName).tag = "?" Then
      Me(ctlName) = Nz(Me(ctlName), 0) + 1
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks Aceman1.. I placed your code in the On Click event for the button and tagged the textboxes as you said but nothing happens. Was I incorrect?
Thanks
 
What about this ?
Code:
Dim ctl As Control
Set ctl = Screen.PreviousControl
If ctl.Tag = "?" Then
  ctl.Value = Nz(ctl.Value, 0) + 1
  ctl.SetFocus
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV! That works great! Thanks to ClydeData and Aceman1 as well..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top