B
Brad Tornberg
Again the paste to a query works fine but when it is put
in VBA it returns 0 records.
Dim cnHistory As ADODB.Connection
Dim rsHistory As ADODB.Recordset
Dim Strsql As String
Set cnHistory = New ADODB.Connection
Set rsHistory = New ADODB.Recordset
cnHistory.ConnectionString = "driver={SQL Server};" & _
"server=2KMAIN;uid=sa;pwd=macola;database=DATA_300"
cnHistory.ConnectionTimeout = 30
cnHistory.Open
Strsql = "SELECT SFORDFIL_SQL.item_no,
SFORDFIL_SQL.ord_status, SFORDFIL_SQL.ord_type,
SFORDFIL_SQL.issue_loc, SFORDFIL_SQL.compl_dt,
SFDTLFIL_SQL.qty, SFDTLFIL_SQL.qty_issued,
SFDTLFIL_SQL.comp_item_no, IMITMIDX_SQL.user_amt FROM
(SFORDFIL_SQL INNER JOIN SFDTLFIL_SQL ON
SFORDFIL_SQL.ord_no = SFDTLFIL_SQL.ord_no) INNER JOIN
IMITMIDX_SQL ON SFDTLFIL_SQL.item_no =
IMITMIDX_SQL.item_no GROUP BY SFORDFIL_SQL.item_no,
SFORDFIL_SQL.ord_status, SFORDFIL_SQL.ord_type,
SFORDFIL_SQL.issue_loc, SFORDFIL_SQL.compl_dt,
SFDTLFIL_SQL.qty, SFDTLFIL_SQL.qty_issued,
SFDTLFIL_SQL.comp_item_no, IMITMIDX_SQL.user_amt HAVING
(((SFORDFIL_SQL.Item_No) like '" & mystr1 & "' ) And
((SFDTLFIL_SQL.comp_item_no) Like 'M*'))ORDER BY
SFORDFIL_SQL.compl_dt DESC;"
rsHistory.Open Strsql, cnHistory, , , adCmdText
in VBA it returns 0 records.
Dim cnHistory As ADODB.Connection
Dim rsHistory As ADODB.Recordset
Dim Strsql As String
Set cnHistory = New ADODB.Connection
Set rsHistory = New ADODB.Recordset
cnHistory.ConnectionString = "driver={SQL Server};" & _
"server=2KMAIN;uid=sa;pwd=macola;database=DATA_300"
cnHistory.ConnectionTimeout = 30
cnHistory.Open
Strsql = "SELECT SFORDFIL_SQL.item_no,
SFORDFIL_SQL.ord_status, SFORDFIL_SQL.ord_type,
SFORDFIL_SQL.issue_loc, SFORDFIL_SQL.compl_dt,
SFDTLFIL_SQL.qty, SFDTLFIL_SQL.qty_issued,
SFDTLFIL_SQL.comp_item_no, IMITMIDX_SQL.user_amt FROM
(SFORDFIL_SQL INNER JOIN SFDTLFIL_SQL ON
SFORDFIL_SQL.ord_no = SFDTLFIL_SQL.ord_no) INNER JOIN
IMITMIDX_SQL ON SFDTLFIL_SQL.item_no =
IMITMIDX_SQL.item_no GROUP BY SFORDFIL_SQL.item_no,
SFORDFIL_SQL.ord_status, SFORDFIL_SQL.ord_type,
SFORDFIL_SQL.issue_loc, SFORDFIL_SQL.compl_dt,
SFDTLFIL_SQL.qty, SFDTLFIL_SQL.qty_issued,
SFDTLFIL_SQL.comp_item_no, IMITMIDX_SQL.user_amt HAVING
(((SFORDFIL_SQL.Item_No) like '" & mystr1 & "' ) And
((SFDTLFIL_SQL.comp_item_no) Like 'M*'))ORDER BY
SFORDFIL_SQL.compl_dt DESC;"
rsHistory.Open Strsql, cnHistory, , , adCmdText