Hiya-
I'm using the self-teach method for VBA, folks, and so far it hasn't been very effective, so bare with me...
i am performing a pass-thru query in VBA using code that i updated from another db. it works fine, however, i would like to have the results appear so i can do a quick, one-time glance at the data.
Can someone please tell/show me how to do this? Thanks in advance!
I'm using the self-teach method for VBA, folks, and so far it hasn't been very effective, so bare with me...
i am performing a pass-thru query in VBA using code that i updated from another db. it works fine, however, i would like to have the results appear so i can do a quick, one-time glance at the data.
Can someone please tell/show me how to do this? Thanks in advance!
Code:
Function PTQ2()
Dim mydb As DAO.Database, myq As QueryDef, thesql As String
Dim myptq As QueryDef
Dim myparams As String
Dim rst As Recordset
Dim strQry As String
Dim strUPC As String
Dim strSep As String
Dim weekBegin, weekEnd, formatWeekEnd
'***********************************
Set mydb = CurrentDb()
Set myptq = mydb.QueryDefs("q 4 midweek results")
myptq.Connect = "ODBC;DSN=tdata;UID=123456;PWD=123456;database=vproddly"
weekBegin = InputBox("Enter Begin Date in YYYY-MM-DD format", "Date Prompt")
weekEnd = DateAdd("d", 7, weekBegin)
formatWeekEnd = Format(weekEnd, "yyyy-mm-dd")
strQry = "SELECT p_upc_id " & _
"FROM [t 1 Item Codes];"
strUPC = "p_upc_id"
strSep = ","
thesql = "select p_upc_id, day_dt, ut_id, tg_sl_am, tg_sl_qt " & _
"FROM DLY_UT_P_AD_HST " & _
"WHERE ut_id in(169, 178, 182, 183, 198, 206, 214, 215, 218, 228) " & _
"AND day_dt BETWEEN Date '" & weekBegin & "' AND Date '" & formatWeekEnd & "' " & _
"AND p_upc_id IN (" & MegaString(strQry2, strUPC2, strSep2) & ")"
myptq.SQL = thesql
myptq.Close
mydb.Close
End Function