I am using the following function call to pull back information from a database and it keeps giving me an OBDC call fail. This is the first time I had to use an inner join in this format. Normally works all the time for any single table query. Also first time using MAX
Code:
Function getMAXPRO(LINE, ITEM) As String
Dim rstRecordset As DAO.Recordset
On Error GoTo errors
'On Error GoTo trap
openconnection
sqlstatement = _
"SELECT MAX(Table1.DSDEAL) FROM Table1 INNER JOIN Table2 on Table1.STR#=Table2.RSSTR# WHERE LINE='" & LINE & "' AND ITEM='" & ITEM & "' AND RSRGN# not in (1,2)"
Set rstRecordset = db.OpenRecordset(sqlstatement, DAO.dbOpenSnapshot)
'get the data
getMAXPRO = rstRecordset.Fields(0).Value
'close the connections and clean up
rstRecordset.Close
Set rstRecordset = Nothing
GoTo noerrors
errors:
MsgBox Error
noerrors:
End Function