Matching title and gender

you put the code in the wrong place. the code should be in the afterupdate event of the title combo. if you think about it logically, it is the change in title that triggers the gender.

now a couple of pointers:

first, compact and repair your database before uploading. this drastically reduces the file size (your original file size upon unzipping was over 2mb. after, it was 356 kb) - you can even set this to happen automatically each time you close the application by settings Office Orb | Access Options | Current Database | compact on close.

second, you would have received your answer a lot sooner if you simply posted the code you were using (all of it - that includes everything from "Private" to "End Sub") we would have immediately seen where you went wrong. "it doesn't work" is like telling a doctor "i'm sick" - the more (relevant) info, the better.
 
you put the code in the wrong place. the code should be in the afterupdate event of the title combo. if you think about it logically, it is the change in title that triggers the gender.

now a couple of pointers:

first, compact and repair your database before uploading. this drastically reduces the file size (your original file size upon unzipping was over 2mb. after, it was 356 kb) - you can even set this to happen automatically each time you close the application by settings Office Orb | Access Options | Current Database | compact on close.

second, you would have received your answer a lot sooner if you simply posted the code you were using (all of it - that includes everything from "Private" to "End Sub") we would have immediately seen where you went wrong. "it doesn't work" is like telling a doctor "i'm sick" - the more (relevant) info, the better.

Run-time error '13':

Type mismatch

Debugger highlights in yellow:
If Me.cboTitle = "Mrs" Or "Miss" Or "Ms" Then
 

Attachments

Change your code to this:
Code:
Private Sub cboTitle_AfterUpdate()
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        Select Case Me.cboTitle
        Case "Mrs", "Miss", "Ms"
            Me.txtGender = "F"
        Case Else
            Me.txtGender = "unk"
        End Select
    End If
End If
End Sub
 
as something somewhat related, there is also that argument that there should only be "Ms" available for women, and here are two reasons:

1) theoretically it does not matter to know a woman's marital status
2) after all, there is only "Mr" for men, and no one wants to know THEIR marital status

edit:

and, if marital status IS important, it should theoretically be important for BOTH men and women, so there should be a SEPARATE field for that, which would include all the various options such as


  • single
  • married
  • separated
  • divorced
  • ...etc
 
Change your code to this:
Code:
Private Sub cboTitle_AfterUpdate()
If Not IsNull(Me.cboTitle) Then
    If Me.cboTitle = "Mr" Then
        Me.txtGender = "M"
    Else
        Select Case Me.cboTitle
        Case "Mrs", "Miss", "Ms"
            Me.txtGender = "F"
        Case Else
            Me.txtGender = "unk"
        End Select
    End If
End If
End Sub

Thanks for this it works great up to a point. When title = Dr, gender is automatically entered as "unk" = unknown, but I need to be able to manually enter M or F? I don't seem to be able to overwrite this "unk"?
 
Thanks for this it works great up to a point. When title = Dr, gender is automatically entered as "unk" = unknown, but I need to be able to manually enter M or F? I don't seem to be able to overwrite this "unk"?

yup. already provided that solution in post # 90 on page 6 ;)

admittedly, this thread has become somewhat of a maze... :rolleyes:
 
This throws up a compile error:

Expected Function or variable

ok, figured it out - victim of air-code. that should be

Code:
            Me.cboGender.SetFocus

not

Code:
            Me.cboGender.SetFocus = True

also, i don't know if you realise, but you've got a combo box for gender with no option in it. people can't actually enter anything (i've just tried). how about you make it textbox, or a combo with values? again, this is something that should probably have it's own table (tblGender) BUT, it's always possible you're one of 1961templar's students ;P
 
Well a big thank you to everyone that has contributed to this thread, especially to: boblarson, Mr. B, Kryst51 and wiklendt. I have now got the Form that automatically enters M (=Male) for Mr and F (=Female) for Mrs, Miss or Ms and the message box "please enter gender" for Dr (or any other non-specific gender title I choose to accept).

However to accept the manual entry of non-specific gender titles I have had to unlock the form, therefore the validation on Mr, Mrs etc. no longer exists in that it is now possible to manually overwrite M and F.

I think the criteria that Mr MUST = Male and Mrs, Miss & Ms MUST = Female is achievable, but as soon as choice is allowed by introducing Dr (etc.) MAY = Male OR Female, validation becomes impossible.

This has been a great learning exercise for me and I truly appreciate all your help.
 

Users who are viewing this thread

Back
Top Bottom