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

Returning text to a table 1

Status
Not open for further replies.

PharmaFun

Programmer
Jul 30, 2003
30
CA
Hi everyone

I have an option group called "Gender" in a form. Selecting male returns a "1" to the table I have. For femlae it is "2". What I'm trying to do is have the table return "Male" or "Female" to the table instead, not a number. I've tried this code (please bare in mind that I am so much an amateur with this stuff!).

Private Sub Gender_AfterUpdate(Cancel As Integer)
If Gender = 1 Then
tbl [Initial Patient Report]![Gender] = "Male"

End If
End Sub

As you guessed, I get all sorts of errors. Please help.

Thanks,
Dean
 
Where does this code reside? It makes lots of diff. I would guess that it resides in a bound form. That means that as you move from record to record, it fills in the data.

Provide more details and I will try to answer your questions.

rollie@bwsys.net
 
Hi Rolliee,

Thanks for offering to help. This is a bound form, since as you enter data in the form, it populates a corresponding table.

Thanks,
Dean
 
I gather that you want this form:

forms![Initial Patient Report]![Gender] = "Male"

This says there is a table behind the form (or report) [Initial Patient Report] which has a field named [Gender]

Now the question must be asked what kind of field is [Gender] If male = 1 and female = 2 then gender is an integer or a long. In which case, to try to put the text in that field would result in an error.

Do you see the sort of analysis that must be done?

Rollie E
 
Thanks again Rollie E. Yeah, I made the necessary changes, but whether the field "Gender" is set to text or integer, it still says "1" in the field for male. Any further suggestions. Sorry, I'm a knob at this stuff.

Dean
 
"1" can be either text or a number. One way add two of them gets you "11" and the other 2. Let's suppose that you want to set the value in forms![MyForm]![Gender] equal to "Male" under a cmd button - not a smart thing to do except as an example. Then the click event of the button would read

private sub command0_click()


me![Gender] = "Male"


exit sub

Rollie E


Remember to reward your tipsters with a star if you feel it worthy. Tips without recognition = less tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top