I have a Query running in Excel at it works perfectly, I need to add a
popup box for the user to enter a date so they don't have to enter MS
query but can stay in Excel.

Now the data I'm pulling is from a .SQL database and I have a date
field that will change each time someone runs the file Example:
2008-05-02.

I have tried to add a inputbox but the data is not returned when I
enter the date in the input box

Any help would be greatly appreiated. I have included my simple query
below.

Range("L3").Select
With ActiveSheet.QueryTables.Add(Connection:=3D _
"ODBC;DRIVER=3DSQL
Server;SERVER=3DHidden;UID=3Dhidden;PWD=3Dhidden);APP=3DMicrosoft=AE
Query;WSID=3DHidden" _
, Destination:=3DRange("L3"))
.CommandText =3D Array( _
"SELECT ae_dt1.field1, ae_dt1.field2, ae_dt1.field3" & Chr(13)
& "" & Chr(10) & _
"FROM Xtender.sysop.ae_dt1 ae_dt1" & Chr(13) & "" & Chr(10) &
_
"WHERE (ae_dt1.field4=3D'2008-05-02') AND
(ae_dt1.field7=3D'CLINTON')")
.Name =3D "Query from Roc_Checker_1"
.FieldNames =3D False
.RowNumbers =3D False
.FillAdjacentFormulas =3D False
.PreserveFormatting =3D True
.RefreshOnFileOpen =3D False
.BackgroundQuery =3D True
.RefreshStyle =3D xlOverwriteCells
.SavePassword =3D True
.SaveData =3D True
.AdjustColumnWidth =3D True
.RefreshPeriod =3D 0
.PreserveColumnInfo =3D True
.Refresh BackgroundQuery:=3DFalse
End With
End Sub

Re: Change Excel query with a inputbox by ward376

ward376
Sat May 10 11:05:08 CDT 2008

You want to use a parameter for the date. You can only use parameters
in Query, not in the Query Wizard.

instead of: WHERE (ae_dt1.field4='2008-05-02')
try: WHERE (ae_dt1.field4=?)
Excel should prompt the user for the criteria value (parameter).

To create a parameter in the msquery interface, use square brackets
(with or without a default) as the value for the date field criteria.
To create a parameter in the sql statment, substitute a question mark
for the date value.

Cliff Edwards