Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set combo box row source (special formated dates) via code. 1

Status
Not open for further replies.

Melagan

MIS
Nov 24, 2004
443
US
Greetings,

I'm wondering if it is possible to generate a recordset of sequential month/year values solely through code. I'd like to use this recordset as the row source for a combo box on a form. The only parameters for the recordset are:

1: "mmm yyyy" format
2: "yyyy" must be in the current year
3: the end result will be a String, probably via CSTR()

The easy solution for this would be to make a lookup table and store the values that I want listed; for kicks, though, I wanted to see if it were possible to do through code instead of making said lookup table.

Any ideas?



~Melagan
______
"It's never too late to become what you might have been.
 
Typed, not tested.
RowSourceType: Value list

strTmp = ""
For i = 1 To 12
strTmp = strTmp & ";" & Format(DateSerial(Year(Date), i, 1), "mmm yyyy")
Next
Me![combo name].RowSource = Mid(strTmp, 2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Bingo - that does it! Thanks again *

I understand all of the logic involved and it was a great introduction to the DateSerial function. The thing I'm curious about is the purpose of the ";" concatentation.
Why couldn't it be:

strtemp = strtemp & Format(DateSerial(Year(Date), i, 1), "mmm yyyy")



~Melagan
______
"It's never too late to become what you might have been.
 
The semi-colon is the row separator.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top