Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2009, 03:30 AM
Authorized User
 
Join Date: Sep 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Month names in combo box

Hello, I'm trying to generate a combo box with the current Month name and Year (mmmm-yyyy) + the next 6 months. Can anyone assist with this. I assume I would need to start with a Date() value to retrive the current month, but can't figure out how to generate the next month/'s in the combo box list.

Thanks in advance!

Dave
 
Old May 22nd, 2009, 07:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

You can do a loop...

Code:
Dim intMonth as Integer
 
Me.cboMonth.RowSourceType = "Value List"
 
For intMonth = 0 To 6
    Me.cboMonth.AddItem Format(DateAdd("m", intMonth, Date()), "mmmm-yyyy")
Next intMonth
I have not tested this.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old May 25th, 2009, 02:43 AM
Authorized User
 
Join Date: Sep 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thankyou Greg. That is exactly what I was looking (hoping!) for.

I have attached the code to the forms On Current event to provide automated date - year selections for a number of different combo boxes.

The code you provided works perfectly.

Thanks again

Dave





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
FILLING COMBO BOXS WITH FOLDERS NAMES moony Classic ASP Professional 0 December 13th, 2005 09:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.