ebergoni
09-12-2001, 04:58 PM
I create an option group(check box) in the form which have a value of 1, 2, 3, etc. this working fine but i want a string value in the table field that has been tick in the check box. How could i convert this numeric value into string in my table field. Any help will be greatly appreciated.
Pat Hartman
09-12-2001, 07:49 PM
Leave the data stored the way it is. Then for reporting purposes, look up the Choose() function to see a method of easily substituting string values for a small list of numeric values. You can use the Choose() function either in queries or in the controlsource of a control on a form.
ebergoni
09-12-2001, 08:05 PM
Hi Pat,
Thanks for the reply. I can't catch up on what you mean on the queries and report. This is my e.g age range field have Under 20, 21-30, 31-40 and 41-50. Can you explain further on how i'll do it in a query and report. Thanks
Pat Hartman
09-13-2001, 01:21 PM
In a query:
Select Choose(YourField,"val1","val2","val3") As TextYourField
From YourTable;
or as the controlsource on a form or report:
=Choose(YourField,"val1","val2","val3")
The following is directly from A97 help:
You can also use the Choose function in a calculated control on a Microsoft Access form or report. For example, you can use the Choose function to set the value of a control based on the value of another field. Set the ControlSource property of the control to an expression containing the Choose function. The expression in the following example can be used to set the ControlSource property of a control based on the value of a field called ShipVia in an Orders table.
=Choose([ShipVia], "Speedy", "United", "Federal")
In the preceding example, if ShipVia contains 1, the Choose function returns the first string, "Speedy". If it contains 2, the function returns the second string, "United", and so on. If ShipVia contains 0, the Choose function returns a Null.
The next example shows how you can ensure that a string is returned even if the field contains 0.
=Choose([ShipVia] + 1, "none", "Speedy", "United", "Federal")
Note In a Visual Basic module, you can use the more full-featured Select Case statement to return a value from a set of several choices.