checkbox values


G

Guest

I would like to make the value of a checkbox that is in a value group display
a text valuer in a field rather than the typical numeric value of 1, 2, 3 and
so on. Something on the order of if a certain box call it Monday is checked
and access made its value a 1 then another field in my table will output a
text value of Monday, rather then showing me the numeric value of 1. I hope
this makes some kind of sense!! Thanks in advance!!

Myron
 
Ad

Advertisements

W

Wayne Morgan

An option group returns the number as you indicate. You will need to format
this later to display it as desired. For example, in a textbox in a report
you may want Monday, Tuesday, etc to be displayed instead of the number.
This could be done by using the following Control Source for the textbox.

=WeekDayName([FieldName] + 1)

Monday is 2, Tuesday is 3, etc. So, if your table has Monday stored as 1,
add 1 to that to get 2.

Another formatting option would be:

=Choose([FieldName], "Monday", "Tuesday", "Wednesday")

Add as many items as you need.
 
G

Guest

Myron,

An option group always has an integer value--this is inherent to the option
group control. You can, of course, *display* more meaningful text by
assigning text to the each button's label. If you need to display the text
in a report or in the result of a query, you have the following options:

- Use a nested IIf statement to calculate a field. Recommended for 2 or
less choices, e.g.,
(=IIf([MyOptionGroup]=1,"Monday",IIf([MyOptionGroup]=2,"Tuesday",""),"")
- Write a custom function to use in the calculation:
Public Function MyText(intOptionGroupVal as Integer) As String
Select Case intOptionGroupVal
Case 1
MyText = "Monday"
Case 2
MyText = "Tuesday"
.... other cases
Case Else
MyText = ""
End Select
End Function
- Create a table that has the matched values, and join the two tables on the
integer field in a query, selecting the text field. This would be my
preference since it requires no programming.

Sprinks
 
G

Guest

Very simple solution. In the After Update event of your option group:

Me.txtDisplayDay = WeekDayName(Me.opgSelectADay, vbMonday)

Using the vbMonday constant will cause WeekDay Name to return "Monday" if 1
is passed, "Tuesday" if 2 is passed, etc.)
 
Ad

Advertisements

G

Guest

Wayne/Sprinks,

Both of your ideas are great!! I will get to work on testing them out!
Since posting this some of the criteria has changed as to what I need it for
but it will still be useful to have!! I will let you know how it works out.
Thanks!!

Myron

Wayne Morgan said:
An option group returns the number as you indicate. You will need to format
this later to display it as desired. For example, in a textbox in a report
you may want Monday, Tuesday, etc to be displayed instead of the number.
This could be done by using the following Control Source for the textbox.

=WeekDayName([FieldName] + 1)

Monday is 2, Tuesday is 3, etc. So, if your table has Monday stored as 1,
add 1 to that to get 2.

Another formatting option would be:

=Choose([FieldName], "Monday", "Tuesday", "Wednesday")

Add as many items as you need.

--
Wayne Morgan
MS Access MVP


Myron Mummey said:
I would like to make the value of a checkbox that is in a value group
display
a text valuer in a field rather than the typical numeric value of 1, 2, 3
and
so on. Something on the order of if a certain box call it Monday is
checked
and access made its value a 1 then another field in my table will output a
text value of Monday, rather then showing me the numeric value of 1. I
hope
this makes some kind of sense!! Thanks in advance!!

Myron
 

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

Similar Threads


Top