PARAMETERIZED PASS-THROUGH QUERY using textbox

  • Thread starter Thread starter CT
  • Start date Start date
C

CT

SUBJECT: PARAMETERIZED PASS-THROUGH QUERY using textbox
on form.

Can this be done? If so what is the SQL code for Access
2000 (and 2003)? I have tried SQL logic from other
applications but have struck out.

Some trys in the where SQL:
like [Forms]![frmNAME].[TextboxNAME]
= [Forms]![frmNAME].[TextboxNAME]
like :[Forms]![frmNAME].[TextboxNAME]
=?
 
You were already told in other newsgroups that it can't be done.

The only way to do it is to dynamically alter the SQL of the query. Using
DAO, it would be something like:

Dim qdfCurr As DAO.QueryDef
Dim strSQL As String

strSQL = "SELECT Field1, Field2 " & _
"FROM MyTable WHERE Field3 Like '" & _
[Forms]![frmNAME].[TextboxNAME] & "'"

Set qdfCurr = CurrentDb.QueryDefs("MyPassthroughQuery")
qdfCurr.SQL = strSQL
Set qdfCurr = Nothing

DoCmd.OpenQuery "MyPassthroughQuery"
 
Thanks for the information. Couldn't initially find
yesterday's post so I thought I did something wrong during
the posting process. Duane Hookom also provided help with
logic.

-----Original Message-----
You were already told in other newsgroups that it can't be done.

The only way to do it is to dynamically alter the SQL of the query. Using
DAO, it would be something like:

Dim qdfCurr As DAO.QueryDef
Dim strSQL As String

strSQL = "SELECT Field1, Field2 " & _
"FROM MyTable WHERE Field3 Like '" & _
[Forms]![frmNAME].[TextboxNAME] & "'"

Set qdfCurr = CurrentDb.QueryDefs("MyPassthroughQuery")
qdfCurr.SQL = strSQL
Set qdfCurr = Nothing

DoCmd.OpenQuery "MyPassthroughQuery"



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



SUBJECT: PARAMETERIZED PASS-THROUGH QUERY using textbox
on form.

Can this be done? If so what is the SQL code for Access
2000 (and 2003)? I have tried SQL logic from other
applications but have struck out.

Some trys in the where SQL:
like [Forms]![frmNAME].[TextboxNAME]
= [Forms]![frmNAME].[TextboxNAME]
like :[Forms]![frmNAME].[TextboxNAME]
=?


.
 
Back
Top