Connecting Tech Pros Worldwide Forums | Help | Site Map

Constant Crosstab Headings & functions to create queries

ITMA
Guest
 
Posts: n/a
#1: Nov 12 '05
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?



Douglas J. Steele
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Constant Crosstab Headings & functions to create 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.

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



"ITMA" <mindyourownbusiness@net.net> wrote in message
news:3fef2907$1_3@mk-nntp-1.news.uk.worldonline.com...[color=blue]
> 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,[/color]
he[color=blue]
> 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?
>
>[/color]


ITMA
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Constant Crosstab Headings & functions to create queries


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?
[color=blue]
> 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.[/color]


Lyle Fairfield
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Constant Crosstab Headings & functions to create queries


"ITMA" <mindyourownbusiness@net.net> wrote in
news:3fef2907$1_3@mk-nntp-1.news.uk.worldonline.com:
[color=blue]
> 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?[/color]

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)
Allen Browne
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Constant Crosstab Headings & functions to create queries


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" <mindyourownbusiness@net.net> wrote in message
news:3fef4873$1_2@mk-nntp-1.news.uk.worldonline.com...[color=blue]
> 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'[/color]
Query[color=blue]
> as a layman would know it in the database window's list of queries?
>[color=green]
> > 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[/color][/color]
RecordSource[color=blue][color=green]
> > for a report equal to the SQL statement itself.[/color][/color]


Closed Thread