I have been working on making my DB DSN-less and I have a bit of a problem. After racking my brain all day over the ODBC connection string to an Informix database and how to link to the tables as recordsets, I have finally got it to work!
But then I tried to QUERY the recordsets....
Here is the SQL String I am using.
And the ODBC connection string code
My problem is on line #7 of the SQL statement. I get "Run-time error '3296'"
"JOIN expression not supported".
After a quick Google search, seems the JOIN statement may not be parenthesized correctly, but I cannot see where. Any help would be greatly appreciated!
But then I tried to QUERY the recordsets....
Here is the SQL String I am using.
Code:
strSQL = "INSERT INTO Logsheet_Table ( Ticket_No, Date_Entered, Time_Entered, Ticket_Date, Cust_Code, Cust_Name, Cust_Address, Cust_AddressA, Cust_Address_2, " & _
"Cust_Address_2A, Cust_City, Cust_CityA, Cust_State, Cust_StateA, Cust_Zip_Code, Cust_Zip_CodeA, Ticket_Type, Status, Sort_Code ) " & _
"SELECT "" & RsHdr.ioqh_nbr & "", Date() AS Date_Entered, Time() AS Time_Entered, "" & RsHdr.ioqh_dt & "", "" & RsHdr.ioqh_cust_cd & "", "" & RsHdr.ioqh_cust_nm & "", " & _
""" & RsCustAddr.custa_frst_ln & "", "" & RsHdrAddr.ioqhe_frst_ln & "", "" & RsCustAddr.custa_scnd_ln & "", "" & RsHdrAddr.ioqhe_scnd_ln & "", "" & RsCustAddr.custa_city & "", " & _
"Trim(["" & RsHdr.ioqhe_city & ""]) AS Cust_City, "" & RsCustAddr.custa_state & "", "" & RsHdrAddr.ioqhe_state & "", "" & RsCustAddr.custa_zip_cd & "", "" & RsHdrAddr.ioqhe_zip_cd & "", " & _
""" & RsHdr.ioqh_type & "", ""OE"" AS Status, ""E"" AS Sort " & _
"FROM ((("" & RsHdr & "" INNER JOIN "" & RsCust & "" ON "" & RsHdr.ioqh_cust_cd & ""="" & RsCust.cust_cd & "") LEFT JOIN "" & RsHdrAddr & "" ON "" & RsHdr.ioqh_id & ""="" & RsHdrAddr.ioqh_id & "") INNER JOIN "" & RsCustAddr & "" ON "" & RsCust.cust_id & ""="" & RsCustAddr.cust_id & "")" & _
"WHERE ((("" & RsHdr.ioqh_nbr & "")=[Forms]![Frm_Logsheet_Today].[txtTicketNo]));"
Code:
Dim Answer, strSQL, strConn As String
Dim Conn1 As New ADODB.Connection
Dim RsHdr, RsCust, RsCustAddr, RsHdrAddr, RsLookup As ADODB.Recordset
strConn = "ODBC;Dsn='';" & _
"Driver={INFORMIX 3.81 32 BIT};" & _
"Host=192.168.1.3;" & _
"Server=dataline_725;" & _
"Service=20000;" & _
"Protocol=sesoctcp;" & _
"Database=ecspro;" & _
"UID=odbc;" & _
"PWD=odbc"
Conn1.Open strConn
Set RsHdr = New ADODB.Recordset
RsHdr.CursorLocation = adUseClient
RsHdr.CursorType = adOpenKeyset
Set RsHdr = Conn1.Execute("SELECT * FROM informix.ioq_hdr")
Set RsCust = New ADODB.Recordset
RsCust.CursorLocation = adUseClient
RsCust.CursorType = adOpenKeyset
Set RsCust = Conn1.Execute("SELECT * FROM informix.cust")
Set RsHdrAddr = New ADODB.Recordset
RsHdrAddr.CursorLocation = adUseClient
RsHdrAddr.CursorType = adOpenKeyset
Set RsHdrAddr = Conn1.Execute("SELECT * FROM informix.ioq_hdr_addr")
Set RsCustAddr = New ADODB.Recordset
RsCustAddr.CursorLocation = adUseClient
RsCustAddr.CursorType = adOpenKeyset
Set RsCustAddr = Conn1.Execute("SELECT * FROM informix.cust_addr")
Set RsLookup = New ADODB.Recordset
RsLookup.CursorLocation = adUseClient
RsLookup.CursorType = adOpenKeyset
Set RsLookup = Conn1.Execute("SELECT * FROM informix.ioq_hdr WHERE ioqh_nbr='" & TicketNo & "';")
"JOIN expression not supported".
After a quick Google search, seems the JOIN statement may not be parenthesized correctly, but I cannot see where. Any help would be greatly appreciated!
Comment