Results 1 to 8 of 8
  1. #1
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112

    Month/Year lookup for combo box

    Hi,
    I want to create a combo box control on my form where users can select which month/year they're making a payment for.

    I could of course create a table and type it in manually but that isn't very practical because I'd have to keep updating it.

    Is there an easier way to do this? I will have to store the Month/Year data into a table though.



    Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Have you considered using a DateTime field and then the calendar to set the value, just forcing the day to be say the 1st of the month?

  3. #3
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112
    Quote Originally Posted by RuralGuy View Post
    Have you considered using a DateTime field and then the calendar to set the value, just forcing the day to be say the 1st of the month?
    Hi RG,
    Do you know of any sample database that shows how I can do this? Thanks.

  4. #4
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    One way...

    https://www.accessforums.net/code-re...mple-7541.html

    But you'll need to modify it to select the 1st of every month as the day.

    (there are a lot of other examples you may want to browse in the Code Repository on this site.)

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    If you bind a control to a dateTime field then ac2007 will put a Calendar control next to it for data entry.

  6. #6
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112
    Thanks RuralGuy, that's good to know.

    pkstormy,
    That's an awesome Calendar app! I'll study it and see how I can "borrow" from it..hehe! Thanks!

  7. #7
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Buakaw,

    Use any part or all of it. The one nice thing I found I like about it is that for any date control field, I use the Onclick button (calendar type button I create next to it) with the following type of code:

    me.myDateField.setfocus
    docmd.openform "CalPopUp"
    Forms!CalPopUp!FormName = "whatever_my_form_name_is"
    Forms!CalPopUp!FieldName = "whatever_my_field_name_is"
    Forms!CalPopUp!SubFormName = "whatever_my_subform_name_is" (or comment out if no subform.)

    There also is code in the CalPopUp form that uses the 'previouscontrol' code but I commented this out. You can test it if you like. I prefer to just copy the code above and paste it for wherever I need it.

    There are some other methods though posted on different MSAccess sites so you may want to browse around. I didn't find any I like so I created this one but you may like one of the other techniques a little better.

    Also keep in mind that MSAccess 2010 has it's own built-in calendar popup - ie. it automatically adds the calendar button/popup next to a date field (and it no longer has the activeX Calendar Control available in the listing for 2010). Upsizing some of our apps to 2010 wasn't so problem-free since it would no longer recognize it (we converted back to 2007). As Allan mentioned, 2007 also does put in it's own calendar button/popup (automatically next to the date field). But they also kept the activeX calendar control in 2007 so all the developers who have been using it over the years, don't have to re-code.

    Thanks for the comments.

  8. #8
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112
    pkstormy, thanks again.

    I'm looking to trigger an event when I change the drop down list in the ActiveX Calendar object, but I can't seem to find any event that triggers based on that.

    E.g. if I change the month from Mar to Nov, or change the year from 2011 to 2009 in the list box.

    Do you know which event gets triggered when either of this happens?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo Lookup
    By b123 in forum Forms
    Replies: 1
    Last Post: 02-24-2011, 11:24 AM
  2. Track capacity changes month by month
    By Nils in forum Database Design
    Replies: 1
    Last Post: 02-18-2011, 03:03 PM
  3. default month and year
    By beefyalby in forum Forms
    Replies: 3
    Last Post: 12-05-2010, 11:40 PM
  4. Combo box lookup confusion
    By redpenner in forum Forms
    Replies: 5
    Last Post: 08-19-2010, 08:45 PM
  5. by year by month
    By nkuebelbeck in forum Reports
    Replies: 21
    Last Post: 03-24-2010, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums