Consulting

Results 1 to 6 of 6

Thread: Select From Inner Join error?

  1. #1

    Select From Inner Join error?

    Hello,

    What are we doing wrong
    i can't get it working

    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim qry As String, i As Integer
    
    qry = "SELECT TBL_ImportList.m_Referentie " & _
            "FROM TBL_List INNER JOIN TBL_ImportList " & _
            "ON TBL_List.ID = TBL_ImportList.ID " & _
            "WHERE TBL_List.m_Customer_Name LIKE '%" & Me.txtfirstname.value & "%'"
    
    cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\Database.ACCDB"
    rst.Open qry, cnn, adOpenKeyset, adLockOptimistic
    error image here

    -Thanks25896325410.jpg

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    The most obvious thing is that the "Like" syntax normally uses the asterix "*" and not "%".
    The other normal thing with Access queries is that you do not need to specify .value when referring to a form field.
    An error description would be better than an error number.
    Have you tried creating this as an actual query first?
    As I have a program that will convert it in to VBA code.

  3. #3
    Hello

    the error message says:
    Values for one or more required parameters are missing.


    Have you tried creating this as an actual query first?
    no because i have no idea how to do that

  4. #4
    Okay i think i found it

       qry = "SELECT TBL_ImportList.m_Referentie FROM TBL_ImportList INNER JOIN TBL_List ON TBL_List.ID = TBL_ImportList.ID WHERE TBL_ImportList.m_Customer_Name = '" & txtfirstname.value & "'"
    works now

    thanks

    -Tim

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Quote Originally Posted by OBP View Post
    The most obvious thing is that the "Like" syntax normally uses the asterix "*" and not "%".
    Not in SQL it's not.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Thank you for your input.

Posting Permissions

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