Jump to content

Using Value Lists for Month and Year


Geoff Shaw

This topic is 6628 days old. Please don't post here. Open a new topic instead.

Recommended Posts

This seems a simple idea, but I can't figure it.

I want to create two fields called 'Month' and 'Year' for data entry via Value Lists (the first listing Jan thro' Dec, the second listing 2005, 2006 and 2007). This is how it is done on those holiday booking web sites.

How do I configure the fields and how do I extract the information from them to form a valid date (assuming the first of each month)?

Link to comment
Share on other sites

Create two value lists, one containing the months and one containing the years. Format each field to display the appropriate list, then create a calculation field with a date result of

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( Month; 1; Year ) )

Link to comment
Share on other sites

Doh!

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( "JanFebMarAprMayJunJulAugSepOctNovDec"; Month; 0; 1 ) + 2) / 3; 1; Year ) )

or

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( ValueListItems( Get(FileName); "Months" ); Month; 0; 1 ) + 3) / 4; 1; Year ) )

I omitted the conversion, sorry!

Link to comment
Share on other sites

Case( not (IsEmpty(Month) or IsEmpty(Year)); Date( (Position( ValueListItems( Get(FileName); "Months" ); Month; 0; 1 ) + 3) / 4; 1; Year ) )

Caution Caution, will only work with abreviations with the lenght of 3 stuffed in the valuelist ... should be reworked in case full words of variable length are required in the popup.

The things are getting tricky when several languages are used based on system settings - Two valuelist are then required one with the names from the systemsetting for the popup and one similar with trailing @@@@'s to make the positioning the start of each word multiplications of the longest month names length. To get the system settings word has the list to be build via the MonthName function.

The reason for going thru all these measures is that this pseudo Case'ing is slightly faster than the genuine.

--sd

Link to comment
Share on other sites

This topic is 6628 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.