Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: Access Forms FAQ


Create your own calendar by gol4
Posted: 19 Jun 01 (Edited 27 Jul 02)

How to Create your own Basic Calendar
Create a form that looks like a calendar by Adding:
1 unbound text box .Name it FirstDate  Set format to mmmm\ /yyyy
Create 42 unbound text boxes name them D0,D1,D2 >>>>D40, D41 ,  6 rows 7 columns
D14,D15,D16,D17,D18,D19,D20, You get the Idea!
(Note) donÆt do them 1 at a time create 7 then copy and paste!
1 label placed above the textboxes with  caption SUN Mon TUE etc..

paste this code in
Start copy below

Private Sub form_open(cancel as integer)
me![FirstDate] = date()  æset starting date to current date
call filldates   æcall function that fills in calendar
End Sub

Private Function filldates()
Dim curday As Variant, curbox As Integer
curday = DateSerial(Year(Me![firstdate]), Month(Me![FirstDate]), 1)'first day of month
curday = DateAdd("d", 1 - weekday(curday), curday)'back to sunday
For curbox = 0 To 41 'need to loop thru 42 textboxes
Me("D" & curbox) = Day(curday)
Me("D" & curbox).Visible = False
If Month(curday) = Month(Me!FirstDate) Then Me("D" & curbox).Visible = True
curday = curday +1 'nextday
Next curbox
End Function

End Copy above
Run your calendar. Enjoy!
To change month or year just change me![FirstDate] then call filldates() again
Place =filldates() in firstdate afterupdate event
or via a button (my preferred)

Private Sub Command1_Click()
Me!FirstDate = DateAdd("m",1, FirstDate)'increase by 1 month
Call FillDates
End Sub

To determine which date is selected in a text box this works well

dim selday as integer, DateSelected as variant
selday = val(me.activecontrol.value)
dateselected = DateSerial(Year(Me![firstdate]), Month(Me![firstdate]), selday)

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close