Matching title and gender

?
hm. and if you're going to have a "save" button, perhaps you also need a "cancel" or "undo" button?

Ye-e...:rolleyes: Is it realy [FONT=&quot]necessary?[/FONT]
[FONT=&quot][/FONT]
 
:confused:I have watched this thread from the beginning but only actually visited once long ago when DCrake posted a function. I am bewildered how this thread's title could possibly lead to more than eighty posts to date.

Then perhaps there is another user out there just like me who just decided that enough was enough at 82 and this has been going on for weeks.:D
 
:confused:I Like yourself only picked up this post today as the forum is pretty quiet. However I have not contributed to it as you suggest. Maybe you got a bit confused by the number of posts, which quite frankly, I am suprised has got to 80+.

David
 
However I have not contributed to it as you suggest.

I know it was a nice function and long ago. Seemed like something you would suggest. I can't even find the post now.

And another user wonders,,,,,, 84 posts??????? Matching title and gender.
 
Sorry for not completely understanding what you really wanted to do.

Create a combo box for the Title. Set the "Limit To List" property to true. Set the the "Row Type Source" property to: "Value List" and then put the values you need to use in the "Row Source" property like: Mr;Mrs;Miss;Ms no quotes.

Create a Text box for the "Gender" field and set the "Locked" property to true.

In the "AfterUpdate" event of the Title combo box put the follow code:

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        Me.txtGender = "F"
    End If
End If

Change "cboTitle" to the actual name of your Title combo box and change "txtGender" to the actual name of your Gender text box.

This will set the Gender value based on the selection made from the Title combo box.

Could this code be modified to allow non-specific gender titles such as Dr?
 
Sorry for not completely understanding what you really wanted to do.

Create a combo box for the Title. Set the "Limit To List" property to true. Set the the "Row Type Source" property to: "Value List" and then put the values you need to use in the "Row Source" property like: Mr;Mrs;Miss;Ms no quotes.

Create a Text box for the "Gender" field and set the "Locked" property to true.

In the "AfterUpdate" event of the Title combo box put the follow code:

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        Me.txtGender = "F"
    End If
End If

Change "cboTitle" to the actual name of your Title combo box and change "txtGender" to the actual name of your Gender text box.

This will set the Gender value based on the selection made from the Title combo box.

Can anyone tell me how to modify this code to accommodate titles that are of non-specific gender e.g. Dr?

Thanks!
 
Can anyone tell me how to modify this code to accommodate titles that are of non-specific gender e.g. Dr?

Thanks!

So if the Title is Dr what do you want it to do?

Surely the purpose of matching Title and Gender is to avoid a Mistake of alloting eg Mr to a Female , but you cannot drive the Title or gender from the other information.

Brian
 
Can anyone tell me how to modify this code to accommodate titles that are of non-specific gender e.g. Dr?

Thanks!

maybe something like:

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        If Me.cboTitle = "Miss" or "Ms" or "Mrs" Then
            Me.txtGender = "F"
        Else
            Me.txtGender = "n/a" '(or "unk" for unknown)
    End If
End If

(or should that be "= Or("Miss","Ms","Mrs")" ? you'll just have to try a few combinations, i'm not fabulous with off-the-cuff code)

the other thing you could have in your people details is a field for title and a separate field for gender, which would make more sense if you need to incorporate more titles (like Dr, Prof., Councilor, Colonel.... etc) and still need to identify gender - if you think about it, most paper forms you fill out have both title, name and gender (usually only M and F, though the odd one does have a third option of which is something like 'not disclosed' or whatever.)
 
maybe something like:

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        If Me.cboTitle = "Miss" or "Ms" or "Mrs" Then
            Me.txtGender = "F"
        Else
            Me.txtGender = "n/a" '(or "unk" for unknown)
    End If
End If

(or should that be "= Or("Miss","Ms","Mrs")" ? you'll just have to try a few combinations, i'm not fabulous with off-the-cuff code)

the other thing you could have in your people details is a field for title and a separate field for gender, which would make more sense if you need to incorporate more titles (like Dr, Prof., Councilor, Colonel.... etc) and still need to identify gender - if you think about it, most paper forms you fill out have both title, name and gender (usually only M and F, though the odd one does have a third option of which is something like 'not disclosed' or whatever.)

Ideally I would like Mr to force gender to M (male) Mrs, Miss and Ms to force gender to F (female) but non-specific gender titles such as Dr, Prof to force manual gender entry. Is this feasible?
 
Ideally I would like Mr to force gender to M (male) Mrs, Miss and Ms to force gender to F (female) but non-specific gender titles such as Dr, Prof to force manual gender entry. Is this feasible?

again, the best setup would be to have two fields in your people table, one with title and another with gender. remembering that if you do this, txtGender would logically be changed to a combo box and really be called "cboGender" or "cmbGender", whatever nomenclature you are following.

you could use the same if statemnt i provided earlier, but change the last "else" bit to something like:

Code:
MsgBox "Please enter a gender.", vbOkOnly
Me.cmbGender.Setfocus = True

you could make the gender field required, but if you do that you have to be prepared to have an "unknown" or "not supplied" option in the dropdown, because it ISN'T always possible to know the gender of people at the time of data entry (e.g., email correspondance, or a paper survey, with a fictional "Dr. Huong Huozhin".... what (usually naive and ignorant) anglo is going to know that Huong is a female name? and how many anglos are savvy to the fact that many asians write Surname Firstname (no comma)?)

anyway, it may be helpful to know your current data entry setup.
 
maybe something like:

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        If Me.cboTitle = "Miss" or "Ms" or "Mrs" Then
            Me.txtGender = "F"
        Else
            Me.txtGender = "n/a" '(or "unk" for unknown)
    End If
End If

(or should that be "= Or("Miss","Ms","Mrs")" ? you'll just have to try a few combinations, i'm not fabulous with off-the-cuff code)

the other thing you could have in your people details is a field for title and a separate field for gender, which would make more sense if you need to incorporate more titles (like Dr, Prof., Councilor, Colonel.... etc) and still need to identify gender - if you think about it, most paper forms you fill out have both title, name and gender (usually only M and F, though the odd one does have a third option of which is something like 'not disclosed' or whatever.)

I can't get this to run?
 
I can't get this to run?

if you describe your problem a little more than "it doesn't work" perhaps we can help.
(that is to say: what is your exact code you are using (and where have you put it), what is your table structure, form setup, are you receiving any error messages? what IS happening, if not what you expect?)
 
I can't get this to run?

The code as posted appears to have three If Statements, and only two EndIf Statements. I am posting a suggested correction. Perhaps wiklendt can verify her intention.

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        If Me.cboTitle = "Miss" or "Ms" or "Mrs" Then
            Me.txtGender = "F"
        Else
            Me.txtGender = "n/a" '(or "unk" for unknown)
        [COLOR=red][B]End If[/B][/COLOR]
    End If
End If
 
if you describe your problem a little more than "it doesn't work" perhaps we can help.
(that is to say: what is your exact code you are using (and where have you put it), what is your table structure, form setup, are you receiving any error messages? what IS happening, if not what you expect?)

I originally used the code suggested by Mr. B. That code worked but when I modified it to match your suggestion it no longer matched gender to title. I have attached a copy for you to see.

Thanks
 

Attachments

The code as posted appears to have three If Statements, and only two EndIf Statements. I am posting a suggested correction. Perhaps wiklendt can verify her intention.

Code:
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        If Me.cboTitle = "Miss" or "Ms" or "Mrs" Then
            Me.txtGender = "F"
        Else
            Me.txtGender = "n/a" '(or "unk" for unknown)
        [COLOR=red][B]End If[/B][/COLOR]
    End If
End If


oops, yes, that extra end if should be there - like i said, disclaimer on the 'off-the-cuff' code!

templar, i'll get to your file soon, i've got to get back into the lab (im' at work).
 
oops, yes, that extra end if should be there - like i said, disclaimer on the 'off-the-cuff' code!

templar, i'll get to your file soon, i've got to get back into the lab (im' at work).

I added the extra "End If" but it still isn't working?
 
When you say "...it still isn't working?" what does that mean? What does it do, etc.?

The code I have been given does not run. If you look at my post 11-23-2009 02:41 PM I have attached a copy of my file (before adding the missing "End If") if you care to take a look?

Thanks.
 
The code I have been given does not run. If you look at my post 11-23-2009 02:41 PM I have attached a copy of my file (before adding the missing "End If") if you care to take a look?

Thanks.

I can't take a look as I don't have 2007 here at work. If you can save it to an Access 2003 or earlier version and upload, I can.
 

Users who are viewing this thread

Back
Top Bottom