Hi:
I need to dymanically create a number of columns using the queryAddColumn function.
I was going to use the loop below. That way each column would have a generic dynamically created name. - <cfloop index="I" from="1" to="#Variables.qProgramDetails.recordcount#">
-
<cfset temp = QueryAddColumn(#this.RecordSet#, "Detail#I#", "VarChar", newArray) />
-
</cfloop>
The problem I'm encountering is that when running that code I get an error that says: "The column name (Detail1) that you specified already exists in this query".
I'm guessing something isn't quite right since apparently on the second iteration of this loop the column name isn't updating to "Detail2".
Any ideas? As always, thanks in advance!! =)
4 5314 acoder 16,027
Recognized Expert Moderator MVP
...or perhaps the query already has a column named Detail1. Is this.RecordSet an empty query before the loop?
Try this: - <cfloop ....>
-
-
<cfset col = "Detail"&#I#>
-
<cfset temp = QueryAddColumn(#this.RecordSet#, "#col#", "VarChar", newArray) />
-
-
</cfloop>
Or try dynamic variables - lookup Evaluate function.
Good luck - CM
acoder 16,027
Recognized Expert Moderator MVP
cymark, welcome to Bytes and thanks for your contribution.
You could do away with the pound signs in the cfset statement, i.e. - <cfset col = "Detail"& I>
In this case, however, the code that you've posted won't make a difference because it does recognise "#I#" to be 1 (see error message).
Hi,
Sorry was a bit quick there.
The following seems to work OK: - <cfset myQuery = QueryNew("")>
-
-
<cfset FastFoodArray = ArrayNew(1)>
-
<cfset FastFoodArray[1] = "French Fries">
-
<cfset FastFoodArray[2] = "Hot Dogs">
-
<cfset FastFoodArray[3] = "Fried Clams">
-
<cfset FastFoodArray[4] = "Thick Shakes">
-
-
-
<cfloop index="I" from="1" to="5">
-
-
<cfset col = "Detail"&I>
-
-
<cfset temp = QueryAddColumn(#myQuery#, #col#, "VarChar", FastFoodArray) />
-
</cfloop>
-
-
-
<cfdump var="#myQuery#">
Creates cols with Detail1, .. to Detail5
Hope it helps...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Donna Sabol |
last post by:
First, I should start by saying I am creating a database to be used by
some very impatient, non-computer literate people. It needs to be
seameless in it's operation from their point of view. I want them to
do as little as possible when they run their reports.
I have a crosstab query that displays usage of items for each month.
It looks pretty much like this:
ITEM DESC UM 12/02 1/03 2/03 3/03 ...ETC.
1 Solution ...
|
by: Penguin |
last post by:
Using Access 97, I've created a grading sheet. To save space, the
subjects
are in vertical columns on a sub-report, like so:
Math Spelling Reading
N C T A A E
U A I C C X
M L M C C P
B C E U U R
E U S R R E
|
by: Amir |
last post by:
I really hope someone can explain this behavior. I have spend quite a bit of
time and tried a bunch of things, so far nothing has worked.
I have a page on which I have a datagrid with template columns. I
perform regular expression validations in the EditItemTemplate for the
fields that require such validation. The datagrid is inside a div tag
to make it scrollable. I have implemented the solution to freeze header
for this grid - the...
|
by: Mac via DotNetMonster.com |
last post by:
Hi all,
I have a datagrid on a form which is not populated until the user enters
selection criteria and clicks a button. Rather than have a blank datagrid
when the form is displayed, I would like to have the columns headings that
are to be displayed actually there. Is this possible?
I know how to create a DataGridStyle programatically and add columns, so I
added this chunk of code to the "page_load" event and nothing happened. Am
I on...
|
by: lorirobn |
last post by:
Hi,
I have a form with several combo boxes, continuous form format, with
record source a query off an Item Table. The fields are Category,
Subcategory, and Color. I am displaying descriptions, not ID's, so I
have to convert the ID's from various lookup tables.
The combo boxes work fine except for subcategory, which is dependent on
category. Depending on category, the drop-down box for subcategory
will display different items. (for...
| |
by: max |
last post by:
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I need to
change some data in the first table and let VB updates the same data in all
other four tables in the right places.
I know it would be possible by using the ForeignKeyConstraint object. I have
created the tables using the DataSet Visual Tool and I know it doesn't
create any ForeignKeyConstraint obj....
|
by: Techhead |
last post by:
I am running into an issue when adding data from multiple columns into
one alias:
P.ADDR1 + ' - ' + P.CITY + ',' + ' ' + P.STATE AS LOCATION
If one of the 3 values is blank, the value LOCATION becomes NULL. How
can I inlcude any of the 3 values without LOCATION becoming NULL?
Example, if ADDR1 and CITY have values but STATE is blank, I get a
NULL statement for LOCATION. I still want it to show ADDR1 and CITY
|
by: Max |
last post by:
Hello,
I have a datagridview object on my form along with some other controls. When the application runs, the datagridview is populated
with data from a database. Although the right number of records is displayed, all the cells in each record are blank. Any idea why?
Thanks,
Max.
|
by: Paul H |
last post by:
I want to base a form on a crosstab query. The query shows statistics
for a user defined period. The column headings will look something
like this:
ClientID Month01 Month02 Month03 etc..
So if the user selects 3 months in the criteria form, there will be 3
(month) column headings, if he selects 6 months, the will be 6
headings.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |