Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am having trouble selecting a name from a dropdown box when the name has an apostrophe in it. O'Conner. You get an error message.

    I think Hans gave me a solution in the Forum awhile ago but I can not find my record of it. I remember he put a Chr code in the coding somewhere. Can anyone help.

    Thanks.

    Paul

    My code is

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmIndividualStudentData"

    stLinkCriteria = "[LNFN]=" & "'" & Me![liststudents] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Me.Form.Visible = False
    DoCmd.Close acForm, "Switchboard"
    DoCmd.Close acForm, "frmViewStudentRecord"

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Try

    stLinkCriteria = "[LNFN]=" & chr(34) & Me![liststudents] & chr(34)

    Presumably your student table has a primary key. It would be better to have that as a hidden first column in the combobox, and use that to find the student.
    You would avoid the problem with the apostrophes and any duplicate names.
    Regards
    John



  3. #3
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That worked.

    Thanks.

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •