If Statement

M

mike

I want to keep count every time a user clicks an option box but i want to
count to display in a text box on the same form. the count should update
automatically each time the option box is selected.

Can someone provide basic help on how to do this? Sounds like an if
statement to me or some conditional expression??

thx in advance for any advice...
 
J

Jeff Boyce

Mike

I'm not sure what you mean by "an option box". Access has an "option
group", but this allows selection of one (and only one) out of the group.

Are you trying to tell how many times something was changed from one option
choice to another? If so, and if folks could close the database down and
re-open it, would you want the count to start over at 0 each time, or carry
forward from the last total?

More info, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

SteveM

You could use the OnClick event of the option box to increment the value in
the count field.

Do you want to store the value or just count the number of times it has been
clicked since opening the form?

Steve
 
M

mike

Jeff,

using option group of option boxes (3). want to track the number of times a
user clicks on one of the 3 options and display the count in a text box. i
need to store the count so i can track the total over time.

thx for your help.
 
M

mike

-i want to store the value

-how do i use the onlick event in the option box to increment a counter and
display that counter in a text box? do i have to store the count in a
variable and then display that variable in the text box?
 
S

SteveM

If you want to store the value, your textbox will have to be bound to a
number field in the table that is the recordsource of your form. Set its
default value to 0.

Then, in the OnClick event of the option group:

MyNumberField = MyNumberField + 1

Steve
 
F

fredg

-i want to store the value

-how do i use the onlick event in the option box to increment a counter and
display that counter in a text box? do i have to store the count in a
variable and then display that variable in the text box?

Add a field to your table.
Field Name "CountClicks", Number datatype, Field Size Integer.

Include this field in the Form's Record Source, then add this field to
your form.

Code the OptionGroup's AfterUpdate event:
Me!CountClicks = Nz(Me![CountClicks])+1
 
M

mike

-do i bound the textbox to a num field in the table by using the input source
property?

-the option group doesnt have an onclick event, should i use the gotfocus
event instead?
 
M

mike

fyi: i want to keep a separate count for each option (3 of them) in the
option group. i have 3 options, level 1, level 2, level 3, i want a separate
count for each level option that is selected...thx:)
 
S

SteveM

-do i bound the textbox to a num field in the table by using the input
source
property?
The ControlSource property.
-the option group doesnt have an onclick event, should i use the gotfocus
event instead?
Click the frame to see the OnClick property. Alternatively, you can use the
AfterUpdate event.

You will have to write code that detects the value of the option group and
increment a value in a related textbox. In this case you need 3 textboxes
bound to 3 fields in your database if you want to store the values. You could
use somthing like:

Select Case MyOptionGroup
Case 1
Me.Textbox1 = Nz(Me.Textbox1,0)+1
Case 2
Me.Textbox2 = Nz(Me.Textbox2,0)+1
Case 3
Me.Textbox3 = Nz(Me.Textbox3,0)+1
End Select

Steve
 
J

Jeff Boyce

Mike

Based on your answers to other responders, are you trying to determine how
many records have option1 chosen, how many have option2 chosen, etc.? Your
initial description sounds like you want to know only that someone clicked
something, no matter how many times they changed their mind on each record.

If you want a count of option1 choices, a simple query, grouping by the
option group's underlying field, will give you the total number of 1's
(option1) in your table's records, the total number of 2's, ...

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
M

mike

jeff,

per your pt, i should've posted this to begin with:

trying to create a way to track incident reports online (currently paper)
using access.

user will use an access form to report an incident, 3 levels of incidents.

main issue is: user A submits 3 level 1 incidents separately and 1 level 2
incidents separately for a total of 4 separate incidents. how do i track
user A has submitted 4 total forms (3 level ones and 1 level two)?

from my limited programming background, i would imagine that user A needs a
independent variable that tracks the number of incidents reported and then a
variable for each level. the variable count should not reset. so over time
i can see how many incident reports a user has submitted.

thx in advance for your feedback:)
 
Top