Temporary Querydef

G

Guest

Could someone tell how I could assign a temporary querydef as a recordsource
to a form? Here's my code.

Set qdfTemp = CurrentDb.CreateQueryDef("")
qdfTemp.Connect = "ODBC;DSN=ClientSql;UID=Test;PWD=Test;DATABASE=Sample"
qdfTemp.sql = str 'This is my sql statement'

With subfrm.Form
.RecordSource = ???(Not sure how to set this)
.Requery
End with

Thanks
 
G

Guest

Hi.
Could someone tell how I could assign a temporary querydef as a recordsource
to a form?

One cannot assign a temporary object as a Record Source. The Record Source
must be a named object, so you'll have to create the query, then delete it
when you are finished using it.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
G

giorgio rancati

Hi,
----
Dim strSql AS String

strSql="Select * From " & _
"[ODBC;DSN=ClientSql;UID=Test;PWD=Test;DATABASE=Sample;].[TableName]"

subfrm.Form.RecordSource = strSql
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top