Log in

View Full Version : [SOLVED:] Select From Inner Join error?



GhostofDoom
01-17-2020, 11:37 PM
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

-Thanks25830

OBP
01-18-2020, 01:54 AM
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.

GhostofDoom
01-18-2020, 08:28 AM
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 :(

GhostofDoom
01-18-2020, 10:00 AM
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

Bob Phillips
01-18-2020, 01:03 PM
The most obvious thing is that the "Like" syntax normally uses the asterix "*" and not "%".

Not in SQL it's not.

OBP
01-19-2020, 02:14 AM
Thank you for your input.