chanman525
IS-IT--Management
Hello to all again,
I have an sql statement that is not interpreting a variable correctly.
Here is the code;
When i use a regular query using the above statement and put in the value of dbo_t211_lbl.status criteria 'Not In (81,92,96,95)' and dbo_t211_lbl.scn_dtn_nbr 'Not In (457,557,996)' the data comes back correctly however it does not when used in the sql string. I assume there is an issue with quotes or something but I have tried different combinations to no avail.
Any thoughts and help would be appreciated and let me know if I need to post more info.
Thanks!
I have an sql statement that is not interpreting a variable correctly.
Here is the code;
Code:
'these two (txt*)are referencing fields in a form and not defined in the code, just wanted to show the values.
txtExcludeStatus = 82,91,95,96
txtExcludeBays = 457,557,996
StrExcludeStatus = "Not In (" & txtExcludeStatus & ")"
StrExcludeBays = "Not In (" & txtExcludeBays & ")"
StrSql = "SELECT dbo_t211_lbl.t211_lbl_nbr, dbo_t211_lbl.itm_num, dbo_t211_lbl.status, dbo_statuscode.status_desc, dbo_t211_lbl.scn_dtn_nbr, dbo_t211_lbl.t207_shp_ack_nbr, dbo_t211_lbl.cust_num, dbo_t211_lbl.add_dt, dbo_t211_lbl.upd_dm, dbo_t211_lbl.lbl_scn_dm, dbo_t211_lbl.upd_id, dbo_t211_lbl.acy_sts_cd, dbo_item.unt_dol_val, dbo_t211_lbl.lbl_seq_ctn_qty, [unt_dol_val]*[lbl_seq_ctn_qty] AS Extended_Cost, dbo_t211_lbl.cel_sts_cd INTO [tblSorterLog_Dispatch_Final]"
StrSql = StrSql & " FROM ([tblSorterLog-Dispatch] INNER JOIN (dbo_statuscode INNER JOIN dbo_t211_lbl ON dbo_statuscode.status = dbo_t211_lbl.status) ON [tblSorterLog-Dispatch].Label = dbo_t211_lbl.t211_lbl_nbr) INNER JOIN dbo_item ON dbo_t211_lbl.itm_num = dbo_item.itm_num"
StrSql = StrSql & " WHERE (((dbo_t211_lbl.status)[COLOR=red] " & StrExcludeStatus & "[/color] ) AND ((dbo_t211_lbl.scn_dtn_nbr) [COLOR=red] " & StrExcludebay & " [/color] )AND ((dbo_t211_lbl.acy_sts_cd)<>70) AND ((dbo_t211_lbl.cel_sts_cd) Not In (70,71,72)));"
DoCmd.RunSQL (StrSql)
When i use a regular query using the above statement and put in the value of dbo_t211_lbl.status criteria 'Not In (81,92,96,95)' and dbo_t211_lbl.scn_dtn_nbr 'Not In (457,557,996)' the data comes back correctly however it does not when used in the sql string. I assume there is an issue with quotes or something but I have tried different combinations to no avail.
Any thoughts and help would be appreciated and let me know if I need to post more info.
Thanks!