Thanks for the reply.
Here is my SQL code, I have tested this and know it works
SQL = "SELECT DISTINCT [GW Sample Info].Well, GWData.
[Sample Name], GWData.Analyte, Analyte.[CAS Number],
Analyte.Type, GWData.Units, [GWData].Concentration" & a &
h & " " & h & a & "[Qualifier] AS Combine, [GWData]!
[Sample Name]" & a & h & "( " & h & a & "[GWData]![Sample
Date] " & a & h & ")" & h & "AS [Name Combine],
GWData.Concentration, GWData.Qualifier, GWData.[Sample
Date] FROM (GWData INNER JOIN [GW Sample Info] ON GWData.
[Sample Name] = [GW Sample Info].[Sample Name]) INNER
JOIN Analyte ON GWData.Analyte = Analyte.Analyte WHERE
((([GW Sample Info].Well) Like" & h & Filtername & h
& "));"
I just need the "filtername" in the like porition of the
SQL statement to be populated with a value for the "MW
Info Table", and the "Well" field. I would like it to
take the first value, run the query and export to excel,
then take the next value and repeat. I am just not sure
how to do this part. Thanks.
-----Original Message-----
If you are creating the SQL statement in code, you need to concatenate the
value into the SQL string.
Example:
strSQL = "SELECT ..... WHERE Table1.Field1 Like """ & Me.txtMyTextbox &
""";"
If you wanted to, you could then assign this to a stored query to edit that.
Example:
CurrentDb.QueryDefs("qryMyQuery").SQL = strSQL
--
Wayne Morgan
Microsoft Access MVP
.