By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Can a SQL Pass Through query use a parameter from a Form Control?

P: n/a
I have a bit of a newbie question (basically stated in the subject of
the posting). If need to get some data out of a SQL Server Database.
Can I use a control from a form to supply a parameter. I've created a
stored procedure with the parameter I need, I just dont know how to
send the data from the form to the SPT query.

So I need to get data out of [Forms]![Form1]![Combo6] to my SPT query.
Can I do it?

Any help is greatly appreciated.

Thanks!

Oct 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

woody wrote:
I have a bit of a newbie question (basically stated in the subject of
the posting). If need to get some data out of a SQL Server Database.
Can I use a control from a form to supply a parameter. I've created a
stored procedure with the parameter I need, I just dont know how to
send the data from the form to the SPT query.

So I need to get data out of [Forms]![Form1]![Combo6] to my SPT query.
Can I do it?

Any help is greatly appreciated.

Thanks!
Assuming you want [Forms]![Form1]![Combo6] to be a numeric parameter of
your pass through query, you can use code such as this to create the
query QRY_PASS_THROUGH:

Dim db As DAO.Database
Dim qdExtData As QueryDef
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT * FROM TBL WHERE FIELD1 = " &
[Forms]![Form1]![Combo6]
Set qdExtData = db.CreateQueryDef("QRY_PASS_THROUGH")
qdExtData.Connect = "ODBC;DSN=???;UID=???;PWD=???;DBQ=???;"
qdExtData.SQL = strSQL
qdExtData.Close
db.Close
Set db = Nothing

The connect string parameters (???) depend upon the data source you are
connecting to.

HTH

Oct 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.