Combo box set values

G

Guest

I have 2 fields:

1)Title combo box: "Mr";"Miss";"Mrs";"Ms"
2) Gender combo box: "M" or "F"

I was wondering how to get the form to insert into the Gender field to "M if
"Mr" is selected from the Title Combo box, and all the other titles to "F"?

Thanks
 
K

Ken Snell [MVP]

Use the AfterUpdate event of the Title combo box:

Private Sub Title_AfterUpdate()
Select Case Me.Title.Value
Case "Mr."
Me.Gender.Value = "M"
Case Else
Me.Gender.Value = "F"
End Select
End Sub
 
F

fredg

I have 2 fields:

1)Title combo box: "Mr";"Miss";"Mrs";"Ms"
2) Gender combo box: "M" or "F"

I was wondering how to get the form to insert into the Gender field to "M if
"Mr" is selected from the Title Combo box, and all the other titles to "F"?

Thanks

I take it that you are never going to use "Judge", "Dr.", "Reverend",
"Senator", "Congressman", etc. as a person's title?

Simple enough to do.
But then there is no need for the Gender combo box at all.
If you wish to keep the Gender field, change the combo box to a
regular text control, bound to the Gender field.

In the Title combo Box AfterUpdate event:
[Gender] = IIf(Me.Comboname = "Mr","M","F")

Again, as long as you have the title, and the gender can only be "M"
or "F", you can use criteria on the Title field to figure out, in a
query, form, or report just what the Gender is, using the same
expression as above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top