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

Constant Crosstab Headings & functions to create queries

P: n/a
Any Google search will show that somewhere out there is a kind spirited
Michel Walsh has been most generous in his time over the years in giving,
in reply to several postings on the matter, a Function as a solution to
holding column headings constant, so that a cross tab query (the fields of
which would otherwise change depending on the input data) can be reliably
used as the basis of another Query, Report or Form. What, unfortunately, he
seems with similar consistency to avoid is telling us all how to actually
use that Function! Anyone got any ideas. Basically, it returns a string
starting "SELECT .....". How can I use a function generating a SQL
statement to actually create a useable Query?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You can create a QueryDef object, and set its SQL property to the SQL
statement generated by the function. As well, you can set the RecordSource
for a report equal to the SQL statement itself.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"ITMA" <mi*****************@net.net> wrote in message
news:3f**********@mk-nntp-1.news.uk.worldonline.com...
Any Google search will show that somewhere out there is a kind spirited
Michel Walsh has been most generous in his time over the years in giving,
in reply to several postings on the matter, a Function as a solution to
holding column headings constant, so that a cross tab query (the fields of
which would otherwise change depending on the input data) can be reliably
used as the basis of another Query, Report or Form. What, unfortunately, he seems with similar consistency to avoid is telling us all how to actually
use that Function! Anyone got any ideas. Basically, it returns a string
starting "SELECT .....". How can I use a function generating a SQL
statement to actually create a useable Query?

Nov 12 '05 #2

P: n/a
I'm still learning the basics of VBA but it sounds to me like a
function-created-query can only be accessed within yet more VBA code ...?
Am I right in thinking I cannot use a VBA function to create a 'real' Query
as a layman would know it in the database window's list of queries?
You can create a QueryDef object, and set its SQL property to the SQL
statement generated by the function. As well, you can set the RecordSource
for a report equal to the SQL statement itself.

Nov 12 '05 #3

P: n/a
"ITMA" <mi*****************@net.net> wrote in
news:3f**********@mk-nntp-1.news.uk.worldonline.com:
Any Google search will show that somewhere out there is a kind spirited
Michel Walsh has been most generous in his time over the years in
giving, in reply to several postings on the matter, a Function as a
solution to holding column headings constant, so that a cross tab query
(the fields of which would otherwise change depending on the input data)
can be reliably used as the basis of another Query, Report or Form.
What, unfortunately, he seems with similar consistency to avoid is
telling us all how to actually use that Function! Anyone got any ideas.
Basically, it returns a string starting "SELECT .....". How can I use
a function generating a SQL statement to actually create a useable
Query?


CurrentProject.Connection.Execute _
"CREATE PROCEDURE qryBlah (parBlah Integer) AS DELETE * FROM tblBlah WHERE
fldTransactionID = parBlah"

ACXP

gives ... for qryBlah

PARAMETERS parBlah Long;
DELETE tblBlah.fldTransactionID, *
FROM tblBlah
WHERE (((tblBlah.fldTransactionID)=[parBlah]));

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #4

P: n/a
No that's not correct.
Sub CreateQueryDAO()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

Set db = CurrentDb()
Set qdf = db.CreateQueryDef("MyQuery")
qdf.SQL = "TRANSFORM ...

Set qdf = Nothing
Set db = Nothing
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"ITMA" <mi*****************@net.net> wrote in message
news:3f**********@mk-nntp-1.news.uk.worldonline.com...
I'm still learning the basics of VBA but it sounds to me like a
function-created-query can only be accessed within yet more VBA code ...?
Am I right in thinking I cannot use a VBA function to create a 'real' Query as a layman would know it in the database window's list of queries?
You can create a QueryDef object, and set its SQL property to the SQL
statement generated by the function. As well, you can set the RecordSource for a report equal to the SQL statement itself.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.