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.
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+.
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.
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.
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.
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.)
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.
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.)
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?)
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.
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
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?
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?
The code that I posted with the correction for the additional EndIf is below. Is this EXACTLY what you are using? If not please post what you are using.
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?