Re: Variabel fieldnames in queries
From: Hans-Joerg Karpenstein <hjkarpenstein_at_psb.de>
Date: Tue, 24 Jul 2001 13:12:40 +0200
Message-ID: <9jjl8j$2qv$1_at_wrath.news.nacamar.de>
Date: Tue, 24 Jul 2001 13:12:40 +0200
Message-ID: <9jjl8j$2qv$1_at_wrath.news.nacamar.de>
Hello,
maybe use the following code:
Assumed: you have a query "Select cm_01 ...
cm_13 from theTable where adn groupby etc"
called thequery
The app is splited into frontend and backend
You have query named dummyquery in the local
frontend
In a module:
sub export_period(exportPeriod as long)
dim dbData as database
dim qry2Export as querydef
set dbData = currentdb()
set qry2Export = currentdb("dummyquery")
'hange the sql-Property
qry2export.sql="Select cm_" +
trim$(format$(exportPeriod,"00")) + " from
thequery "
set qry2Export = nothing
'Here is the code for the export
docmd.transfertext ......
HTH
-- Hans-Joerg Karpenstein mailto:hjkarpensteine_at_psb.de <fluctuat nec mergitur> "R. Groot Beumer" <Info_at_RGBplus.nl> schrieb im Newsbeitrag news:IvE07.179673$u5.3522685_at_zwoll1.home.nl...Received on Tue Jul 24 2001 - 13:12:40 CEST
> Hello (again),
>
> I have a question about the use of variabel
fieldnames in queries. In a
> table of mine I've worked with cummulatives.
The tables has got (among
> others) 13 fields which are named: cm_01,
cm_01, cm02 etc (last one is
> cm_13).
> In a certain query I want to get the values
of one of the above fields by
> using a variabel (perhaps a function). So
the user is asked: "Which period
> do you want to export". The system must take
the right field. In simple VBA
> this is done with: Me("cm_" & [period])
but how is this done within a
> query.
>
> As usual: any help is appreciated !!
>
> Thanx,
>
> Remco (Holland)
>
>