'Serving the Microsoft® Access
Community since 1997'

Free Samples
About Us



Custom Calendar Form in MS Access - Part 4

In Part 1 of this article on creating a "pure" Access date picker (aka calendar), we got as far as labelling all the days of the current month.

In Part 2 we made our calendar look better, and learned how to use some VBA to allow the user to change the displayed month and year.

In Part 3 we integrated the calendar into other forms.

Here in part 4 we will switch some text boxes to drop down combo boxes.

(article continues after sponsor spot)

Combo boxes can often make life easier. Let's use the concept for our Month text box.

NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here.

With the form open in design mode:

  1. click once on the month's text box
  2. in the Access menu choose Format, Change To, Combo Box
  3. open the properties for the new combo box
  4. change the name to "cboMonth"
  5. the Control Source and Format properties should be blank
  6. change the Row Source Type to Value List
  7. change the Row Source to "1;January;2;February;3;March;4;April; 5;May;6;June;7;July;8;August; 9;September;10;October;11;November;12;December" (Note: I have spaces after April and August only because of space on this page; do NOT include spaces in your property; ALSO the quotes are just for emphasis, do NOT include the quotes)
  8. Column Count is 2
  9. Column Widths is 0cm;2.54cm
  10. Bound Column is 1
  11. List Rows is 12
  12. List Width is 1 inch or 2.54 cm
  13. Limit to List is Yes
  14. add the following code to the combo box's After Update event
    Private Sub cboMonth_AfterUpdate()
        myMonth = cboMonth.Value
        Call basCreateCalendar
    End Sub
  15. now we have to find all the references we had to intMonth and change them to cboMonth, and delete any intMonth code no longer needed as the combo box now takes care of it all automatically
  16. we also no longer need the strMonth variable or the code that handles it, or any code that references txtMonth
  17. sorry we have to hack at our code so much, but I needed you to see this in a very obvious way, and what better obvious way than one that undoes a lot of hard work :-(
  18. after fixing the code, try the Compile command under the Debug menu; it will show you any errors

NOTE: if you really get stuck on code, click here to see all the new code, BUT only do that as a last resort. Struggling to find your own errors will make you a better "coder" in the long run, rather than just copying the answer !!!

Note: This web site dedicated to MS Access database users is an independent publication of Richard W. Killey and is not affiliated with, nor has it been authorized, sponsored, or otherwise approved by Microsoft® Corporation.


© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. - Privacy Policy