Error!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlowry
    New Member
    • Oct 2006
    • 10

    Error!

    When clicking a name in my list box i get the following....

    Run time error 3075
    Syntax Error (comma) in query expression 'contactID=will iams, michael'.

    Private Sub LstCName_DblCli ck(Cancel As Integer)
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmcontact s"
    stLinkCriteria = "ContactID= " & Me.LstCName

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    Try :-
    Code:
    stLinkCriteria = "ContactID='" & Me.LstCName & "'"
    I added quotes around the string.

    Comment

    • dlowry
      New Member
      • Oct 2006
      • 10

      #3
      Unfortunately this still doesnt pick any information up.... any other ideas ?

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        Originally posted by dlowry
        Unfortunately this still doesnt pick any information up.... any other ideas ?
        Did that fix the error message?
        If not then I need to know the current situation.
        If it did and you're asking for further help, then perhaps you wouldn't mind explaining what the new situation is.
        I AM psychic, but it's not THAT reliable.

        Comment

        • PEB
          Recognized Expert Top Contributor
          • Aug 2006
          • 1418

          #5
          Are you sure that contaqct Id has information about the names and isn't a number for exemple?

          ;)

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by dlowry
            When clicking a name in my list box i get the following....

            Run time error 3075
            Syntax Error (comma) in query expression 'contactID=will iams, michael'.

            Private Sub LstCName_DblCli ck(Cancel As Integer)
            Dim stDocName As String
            Dim stLinkCriteria As String

            stDocName = "frmcontact s"
            stLinkCriteria = "ContactID= " & Me.LstCName

            DoCmd.OpenForm stDocName, , , stLinkCriteria

            End Sub
            I would guess that your ContactID is an ID field and not the actual Name. In which case. Assuming your Name field is called ContactName.

            Code:
             
            Private Sub LstCName_DblClick(Cancel As Integer)
            Dim stDocName As String
            Dim stLinkCriteria As String
             
              stDocName = "frmcontacts"
              stLinkCriteria = "[ContactName]='" & Me.LstCName & "'"
             
              DoCmd.OpenForm stDocName, , , stLinkCriteria
             
            End Sub

            Comment

            • dlowry
              New Member
              • Oct 2006
              • 10

              #7
              Right ok - I've now changed the values in tblcontacts. ContactID still exists with new entries.What was MJW is now changed to williams, michael. This now displays the form in full (frmcontacts). I would like to keep my ContactID as MJW. Any chance ?

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                Have two fields as follows:

                tblContact
                ContactID with a value like MJW
                ContactName with a value like Williams, Michael

                Set up your listbox properties as follows:

                LstCName

                Under the Data tab ...

                Row Source Type "Value List"
                Row Source "SELECT ContactID, ContactName FROM tblContact";
                Bound Column 2

                Under the Format tab ...

                Column Count 2
                Column Widths 1.5 cm; 4 cm (If you want to see ContactID)
                OR
                Column Widths 0 cm; 4 cm (If you want to hide ContactID)


                This code should still work

                Code:
                 
                Private Sub LstCName_DblClick(Cancel As Integer)
                Dim stDocName As String
                Dim stLinkCriteria As String
                 
                stDocName = "frmcontacts"
                stLinkCriteria = "[ContactName]='" & Me.LstCName & "'"
                 
                DoCmd.OpenForm stDocName, , , stLinkCriteria
                 
                End Sub

                Comment

                Working...