CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 calendar with year and month only

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 11/20/2006, 3:14 AM

Hi all

I've had a request to develop a screen that provides the user with the ability to select a month and a year only (no date on month required). I think there are two possible ways of doing this.

One is a popup calendar containing only month and year values (but I can't find one like this).

The second is to create two dropdown boxes one containing the month and on a list of years. But I can't work out how to get these to update one field with the month and year values (plus probably set the day to the first of the month).

I'm using ASP with SQL 2000.

any help would be greatly apprciated.

many thanks

rob
View profile  Send private message
Edd


Posts: 547
Posted: 11/20/2006, 4:11 AM

Rob

Why not just one dropdown with the months and years together.

I had a project ages ago where we were asked to have 2 dropdowns - we gave them what they wanted (Javascript to the resue) and then we asked them to try the single drop down - they preferred the single dropdown as they could use the wheel mouse facility and we just prepopulated the listbox with 10 years of months / years.

Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
robn

Posts: 70
Posted: 11/20/2006, 5:45 AM

Thanks for the advice Edd I like the idea of a single dropdown.

Did you create the dropdown from a table (one containing the display dates and the insert date format) or did you do it another way?

any examples or advice would be great

thanks again

Rob
View profile  Send private message
Edd


Posts: 547
Posted: 11/20/2006, 2:29 PM

Firstly look at the reference in the help

Examples & Techniques >> Programming >> Customising the DataSource >> Dynamically Modify the "List Of Values" of a ListBox

Add a Listbox on your screen with a datasource ListOfValues

Then in the "BeforeSHow" of the record you will need to construct an array of dates and change the datasource to that array of dates:

  
Dim ArrayDatesStr  
Dim ArrayDateDte  
Dim DteItm  
  
Dim StartDate  
Dim StartDateStr  
Dim EndDate  
  
StartDate	=	Date()  
'To Get a Univeral Date Format YYYY-MM-DD where DD is always 1st of the month   
StartDateStr =    Right("0000" & Cstr(DatePart("yyyy",StartDate)),4) & "-" & _   
				  Right("00" & Cstr(DatePart("m",StartDate)),2) & "-01"  
StartDate	 =  CDate(StartDateStr)		    
  
' Go back 5 years and then have a 10 year spread  
StartDate =	DateAdd("yyyy", -5, StartDate)  
EndDate = DateAdd("yyyy", 10, StartDate)  
  
ReDim ArrayDatesStr(0)  
ReDim ArrayDateDte(0)  
DteItm	=	-1  
  
' Loop through the dates populating the array  
  
Do Until StartDate > EndDate  
	DteItm	=	DteItm + 1  
	ReDim Preserve ArrayDatesStr(DteItm)  
	ReDim Preserve ArrayDateDte(DteItm)  
	'Dates are stored as string  
	ArrayDatesStr(DteItm) = CCFormatDate(StartDate, Array("mmmm",", ","yyyy"))  
	ArrayDateDte(DteItm) = CCFormatDate(StartDate, Array("mm","-","dd","-","yyyy"))  
	'The following will return the 1st date of every new month  
	StartDate = DateAdd("m",1,StartDate)  
Loop  
  
Set Assist_ConsumablesSearch.LBMonth.DataSource = CCCreateDataSource(dsListOfValues, Empty, Array(ArrayDateDte,ArrayDatesStr))  

Regards
Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
robn

Posts: 70
Posted: 11/21/2006, 4:08 AM

Thanks Edd

I've tried your code but get the following error message when trying to publish

Warning:ListBox ListBox1: Wrong List Source property value.
Error:Compiled file error
Source: InitializeSimpleDS "ListBox1", Template name: Class
Description: Function 'getOptionValue' did not return a value, or it returned a value that cannot be converted to an XSL data type.

I set the Control source to the field I am after retreiving
The connection to my current connection
And the Data Type to Date (This appeared to cause the second part of the error, setting the Data Type to text opened the page but did not retreive any of the stored values (table field set to smalldatetime).

any help or suggestions would be much appreciated.

many thanks

Rob
View profile  Send private message
Edd


Posts: 547
Posted: 11/21/2006, 5:51 AM

Rob,

Are your sure your listbox datasource is List of Values (You can put some dummy entries if you wish)

Regarding the listbox - is this in a Record form or a Search form? I must admit I thought it was a search form.

OK the same thing applies but change the updating date format to universal ("yyyy","-","mm","-","dd") instead of ("mm","-","dd","-","yyyy"). And in the DBFormat in the bottom of the properties should be changed to match.

Edd



Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
robn

Posts: 70
Posted: 11/23/2006, 9:34 AM

Hi Edd

thanks for your response, I've now got the page loading ok (no error message on load).

It's actually an editable grid I'm trying to you the date format for. The problem is I can now get the list of values up but it does not return the results of any inserted values (just shows select value even when there is a date associated with the record). i've set the control source to the date field required. Also when I do an insert it appears to not save any changes.

Any help with this would be great I'm really struggling with this one. Also another option could be to use a caledar popup that only shows month and year, but I can't find one anywhere, if anyone knows of one that would be great as well.

thanks again

Rob
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.