Hmmm....
when I turn on the recorder, then right click in the returned data, select edit query, (then msquery opens)
then select file>retun data to msexcel, then stop the recorder,....when i look at the code, i get a statement that includes the sql (as above) ...you can concatenate (splice) variables into the sql...
....this maybe easier to define if you add a criteria while in the msquery editor just to help you find the line in the sql statement where you need to splice in a variable.
as I did in the "where" portion of the following code returned by the recorder.
I also added the cell refs to pick up dates (you'll use your select or edit box maybe.....
the origional msquery had a criteria for a field called
TEVAL.DTEVLCMP ...so i replace the hard date with a variable
made up of conditionals and the SELECT_DATE$ variables.
------------------------------------------------------
Sub set_date()
'
' set_date Macro
' Macro recorded 3/7/2002 by xyz.
'
'
SELECT_DATE$ = Sheets("npets_data_closed"

.Range("U1"

SELECT_DATE2$ = Sheets("npets_data_closed"

.Range("U2"
MsgBox (SELECT_DATE$ + " - " + SELECT_DATE2$)
Sheets("npets_data_closed"

.Range("A1"

.Select
With Selection.QueryTable
.Connection = "ODBC;DSN=NPETS ODBC;"
.CommandText = Array( _
"SELECT TEVAL.EVALNUMB, TEVAL.DTPRERVW, TEVAL.PRERVWST, TEVAL.LOCATION, TEVAL.DTEVLCMP, TEVAL.ACTION, TEVAL.STATUSX, TEVAL.DTCHANGD, TEVAL.USERIDNO" & Chr(13) & "" & Chr(10) & "FROM LAB400T.NPETPROD.TEVAL TEVAL" & Chr(13) & "" & Chr(10) & "WHERE (TEVAL.STAT" _
, "USX='COMPLETED') AND (TEVAL.DTEVLCMP<" + SELECT_DATE$ + " And TEVAL.DTEVLCMP>" + SELECT_DATE2$ + "

"

.Refresh BackgroundQuery:=False
End With
Sheets("npets_data_closed"

.Visible = False
End Sub
----------------------------
Hope this helps
