Welcome! Log In Create A New Profile

Advanced

Forcing a Combo to display a list item

Posted by Clarion Ghost 
Clarion Ghost
Forcing a Combo to display a list item
April 25, 2012 01:19PM
I have a Combo List which Displays:-

2005
2006
2007
2008
2009
2010
2012
2013

To force the display of 2006 I can use

COMBO_Year_List = 2

What do I use to force the display of the current year while not knowing where in the list it will appear?

Many Thanks



Edited 1 time(s). Last edit at 04/25/2012 04:48PM by Clarion Ghost.
DarrenF
Re: Forcing a Combo to display a list item
April 25, 2012 07:05PM
Hi Ghost,

As long as the current year is > the 1st year in your combo, you could always do a quick calculation - something like:

COMBO_Year_List =  (CurrentYear - COMBO_Year_List[1]..DisplayedValue) + 1

Not tested, but it's a starting point...?
Piet van Zanten
Re: Forcing a Combo to display a list item
April 25, 2012 07:28PM
Hi,

If you read some of our posts (mine :-)) more carefully, you would already know that gLink is your friend.

Piet
DW <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: Forcing a Combo to display a list item
April 25, 2012 07:35PM
look at ListSeek() in the help

DW
Clarion Ghost
Re: Forcing a Combo to display a list item
April 25, 2012 11:20PM
Hi Piet,

I have been looking at gLink, but I do not understand how to apply it.

COMBO_Year_List = 11 . // displays 11th element in list

The Year 2012 can vary in position in the list.

As I am understanding it, the number "11" is the gLink. I would have to know the gLink number of the element which identifies 2012 in order to display it. How do I find out which gLink number is associated with the element containing 2012

Many Thanks
Arie
Re: Forcing a Combo to display a list item
April 26, 2012 09:20AM
Clarion, the friendly ghost,

I guess you fill the combo by programming, looking at your other post.
Then you have to add that glink value yourself
ListAdd(ListAdd(Combo_Year, nYear + gLink(nYear) )

Then it will use the gLink value instead of the position of the line, i.e.
Combo_Year = 2012
will select the row holding the year 2012

You can also link your combo to a datasource directly. See the content-tab of the description-pages of the combo. And the use the 'stored value' for this purpose.
But in your case, where you do some reformatting of the data, I would go for 'filled by programming'. I don't see an easy way to get those years by using some kind of query.
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 02:27PM
Hi Arie,

Ghost, you are right!

Yes, I am getting into all sorts of trouble with this little learning exercise, but I suppose that was the objective. gLink has helped me, but I still have a way to go. It seems to be all about programming the memory combo box. Got the combo year box to build the year element from 1200 to 2999 based on records it found, it worked brilliantly. I am not sure what the maximum date range is, but when I find out I will try that.

What I am finding out is how little I know as a newbie! I do feel a bit stupid when asking simple questions (On re-reading, sometimes I don't even understand my own questions.) but I have had a lot of encouragement and help which has been brilliant.

Now that I have a Combo_Month_List and a Combo_Year_List, I am trying to work out how to create a date from the two displays?

As Arnie put it "I'll be back!"
Al <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: Forcing a Combo to display a list item
April 26, 2012 02:39PM
Hello Ian

Presumably your month combo displays alpha values Jan to Dec. If you add their numeric values "01" to "12" using Glink then that info plus your year combo and a day value from 1-31 you have all the number components of your date to construct a date string as yyyymmdd.

According to the help, dates can range as follows:
Date (YYYYMMDD): a date in YYYYMMDD format (dates included between the 01/01/0001 and the 31/12/9999)

Regards
Al
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 03:05PM
Hi Al,

Yes, that is right. January to December returns 1 to 12. Therefore Combo_Month_List returns 1 to 12. The Combo_Year_List is a real challenge as the Combo displays Years based on a Transaction file in which the oldest and newest dates can change. This in turn can change the number of entries in the Combo_Year_List box. Currently I am trying to work out how to recover the displayed year date to build yyyymmdd to use as a param in the Transaction query. Ouch!
DW <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: Forcing a Combo to display a list item
April 26, 2012 03:31PM
Hey Ian

Combo_Year_List..DisplayedValue + Combo_Month_List..StoredValue + Your Day

DW
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 04:54PM
Hi DW,

Thanks for the much needed push, that almost works.

This is what I now have:-

StartDate int
StartDate = Combo_Year_List..DisplayedValue + COMBO_TxMonth + 01

is giving me 201241 where I am looking for 20120401.

Is there anyway I can retain the leading zeros
Arie
Re: Forcing a Combo to display a list item
April 26, 2012 05:13PM
Something like this will do

StartDate int
StartDate = Combo_Year_List..DisplayedValue + Right("0"+COMBO_TxMonth,2) + 01
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 05:28PM
Thanks again Arie,

StartDate = Combo_Year_List..DisplayedValue + Right("0"+COMBO_TxMonth,2) + "0" + 1 returns 2012041. Almost made it.

How do I add 01, 02, 03, 04 etc to the end of the date line? It doesn't like +0 or "0"?
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 05:38PM
Back again:-

StartDate = Combo_Year_List..DisplayedValue + Right("0"+COMBO_TxMonth,2)
This returns 201204

StartDate = (StartDate * 100) + 1 // This works, but is it the right way to do it?
This Returns 20120401

(Memories of Clarion)
Arie
Re: Forcing a Combo to display a list item
April 26, 2012 05:39PM
Most probably you have the situation of a implicit conversion.
The 1 is treated as a number a added to "0". Which is first converted to 0
0+1 = 1
And it is converted back to string again.

Well: you have to get familiar with int, string and so on.

Mmh, now I see you define StartDate as INT.
This should be
StartDate is DATE

But another way would be this
StartDate is DATE
StartDate..Year = Combo_Year..DsiplayedValue
StartDate..Month = Combo_Month
StartDate..Day = 1
That's it!
Clarion Ghost
Re: Forcing a Combo to display a list item
April 26, 2012 05:54PM
Thanks Arie, that works.

So near and yet so far. I am a bit of a trial and error merchant. Always much easier when you know how.

Many Thanks,

On to the next challenge!
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: