473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem passing variables...

139 100+
Hello,

Trying to export the results of a query into a spreadsheet, which I can do, but not as I like.

Procedure is this:

Form holds 2 date fields - ToDate, FromDate

query_CreateShowTable.cfm shows the results as a table with all completed records within that date range. On the web page is a button with 'Export to Excel' on it. This exports the results to XLS format using the action query query_ExportToExcel.cfm

I'm exporting to XLS by running this query, but it doesn't work as the query requires the values of ToDate & FromDate from my form.

How can I pass the values of ToDate & FromDate to the query _ExportToExcel.cfm?

Thanks
Neil
Oct 12 '10 #1

✓ answered by acoder

Ah right. The URL should of course be in <cfoutput> tags otherwise it'll just be a string #fdate# instead of the actual value of the variable.

9 2682
acoder
16,027 Expert Mod 8TB
You can use something like:
Expand|Select|Wrap|Line Numbers
  1. exportToExcel.cfm?FromDate=#FromDate#&ToDate=#ToDate#
Oct 12 '10 #2
ndeeley
139 100+
Hi acoder,

I've tried that, but it doesn't seem to be accepting the value of the ToDate.

Here's the links action:

Expand|Select|Wrap|Line Numbers
  1. <a href="action_CreateExcelReport.cfm?DateFrom=#DateFrom#&DateTo=#DateTo#" title="Export report to Excel .csv format" onMouseOver="window.status='Export report to Excel .csv format';return true;"><img src="assets/excel.png" /></a>
  2.  
and here's the handling script of the action_CreateExcelReport.cfm:

Expand|Select|Wrap|Line Numbers
  1. <cfquery datasource="taskbook" name="JobReport">
  2. select         ID,
  3.             CustomerName,
  4.             Dept,
  5.             Location,
  6.             ContactNo,
  7.             EmailAddress,
  8.             ChargeCode,
  9.             RequestDate,
  10.             TaskTypeFK,
  11.             TaskDetails,
  12.             JobStatusFK
  13. from        tblTaskBooker    
  14. where        ChargeableYN = 1 and JobStatusFK like 'Completed'
  15.             and ((RequestDate BETWEEN #DateFrom# AND #DateTo#) or (RequestDate Is Null))
  16. order by    CompletionDate
  17. </cfquery>
  18.  
Anything I am doing wrong here?
Oct 13 '10 #3
acoder
16,027 Expert Mod 8TB
Yes, when passed to the page via the URL, they can be accessed as #url.DateFrom# and #url.DateTo#.
Oct 13 '10 #4
ndeeley
139 100+
Thanks, I have changed that, but now I`m getting this error:

Parameter 1 of function CreateODBCDate which is now "" must be a date/time value

It's not passing the value for some reason.I've tried outputting it at the top of the page but its empty.
Oct 13 '10 #5
acoder
16,027 Expert Mod 8TB
What's the value in the URL? Are you seeing "action_CreateExcelReport.cfm?DateFrom=&DateTo =" in the address bar? If so, you need to check the values before they're passed on the CreateShowTable.cfm page.
Oct 13 '10 #6
ndeeley
139 100+
Sort of...what I am seeing is this:

http://marlin/assetinl/scripts/TaskB...e&DateTo=tdate

I'm creating two variables to hold the dates:

Expand|Select|Wrap|Line Numbers
  1. <cfset fdate = '#form.QuickRpts_DateFrom#'>
  2. <cfset tdate = '#form.QuickRpts_DateTo#'>
  3.  
Then passing those variables along the url string:
Expand|Select|Wrap|Line Numbers
  1. <a href="action_CreateExcelReport.cfm?DateFrom=#fdate#&DateTo=#tdate#" title="Export report to Excel .csv format" onMouseOver="window.status='Export report to Excel .csv format';return true;"><img src="assets/excel.png" /></a>
  2.  
and I have outputted the values at the bottom of the page (ie the one with the export to excel button on it) and it is showing the correct date values:

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>
  2. #fdate# <br />
  3. #tdate#
  4. </cfoutput>
  5.  
of
01/09/2010
01/10/2010

so I have no idea where I am going wrong!
Thanks for your help!
Neil
Oct 13 '10 #7
acoder
16,027 Expert Mod 8TB
Ah right. The URL should of course be in <cfoutput> tags otherwise it'll just be a string #fdate# instead of the actual value of the variable.
Oct 13 '10 #8
ndeeley
139 100+
Brilliant - got it all to work!

Thanks for all your help.

Cheers
Neil
Oct 13 '10 #9
acoder
16,027 Expert Mod 8TB
No problem. Glad to :)
Oct 13 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: lawrence | last post by:
Those of you with backgrounds with the C language will laugh at my mistake, but those of you, like myself, who deal mostly with PHP should be warned about passing variables as references -...
7
by: Matthew Robinson | last post by:
i read a tutorial the other day on passing variables between php pages using a html form and setting the action to the php page to parse, can anybody see anything wrong with the code below? the...
2
by: Chieko Kuroda | last post by:
Hello all, I would like to learn the syntax for passing variables that I retreived from a database to a second asp page. Currently, I'm using: Response.Write "<tr><td>&nbsp;</td><td><Font size=...
1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
7
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
1
by: Rotsen | last post by:
HI people, I am trying to read a file using "file" and I am passing the following string for the input file parameter:...
3
by: jsdeveloper | last post by:
Hi, I just started programming in javascript, and I'm having a problem passing variables between javascript and asp code in .asp page. Can you please help? I've given the sample code below. ...
6
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
6
BezerkRogue
by: BezerkRogue | last post by:
This is the most fundamental action I am sure, but I can't seem to make it happen. I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.