April 9th, 2003, 07:24 AM
need to convert the value of a field in an access db to another value
I have a field in my db called "Gender" it can have values "Male" or "Female". I will be printing this information onto a pre-printed form which has cross-boxes/check-boxes for male and female. I have created fields in a query called "MaleX" and "FemaleX". These fields contain the same value as gender. I need two functions. In the "MaleX" field it will convert the value in the Field to an "X", if the value is "Male" else it will convert it to a null. In the "FemaleX" field it will convert the value in the Field to an "X", if the value is "Female" else it will convert it to a null.
I know this sounds easy but when I can get the value into the field.
In the query, I have the fields as
The code I tried doesn't work but probably explains the problem better than I have
Public Function convertFemale(strInput As String)
If (strInput = "Female") Then
strInput = "X"
strInput = null
Hope someone can help I really don't know very much about vb
April 9th, 2003, 07:45 AM
Rather than using an additional VB function, I used the IIf statement, which evaluates a condition and returns a value depending on whether the condition is true or false.
I changed the calculated fields in your query to:
That did it