Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    2

    Access - Calendar Control


    I'm trying to use a calendar in Access 2003 to enter data in data fields.
    I found a site that showed how to write the code so it will popup when you click on the date field and then disappear when you select the date from the calendar.
    I got it working but I want to be able to access that same calendar for other date fields on the form.
    So I used a variable call 'originator' to pass the originators name to the variable.
    Only thing is...now it doesn't work. I get a type mismatch error and I don't know why. It's exactly the same as the example I found(obviously with my names substituted in).

    Please help. (dob is the field I want the date to go into and Calendar6 is the name of the calendar I'm using.) Here's my code:


    Option Compare Database
    Option Explicit
    Dim originator As ComboBox

    Private Sub dob_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Set originator = dob
    Calendar6.Visible = True
    Calendar6.SetFocus

    If Not IsNull(originator) Then
    Calendar6.Value = originator.Value
    Else
    Calendar6.Value = Date
    End If

    End Sub

    Private Sub Calendar6_Click()
    originator.Value = Calendar6.Value
    originator.SetFocus
    Calendar6.Visible = False
    Set originator = Nothing

    End Sub

  2. #2
    Join Date
    Apr 2009
    Posts
    7
    Try this:
    Private Sub dob_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Calendar6.Visible=True
    Calendar6.SetFocus
    If Not IsNull(dob) Then
    Calendar6.Value = dob.value

    Else

  3. #3
    Join Date
    Apr 2009
    Posts
    7
    Avoid the last one. for some reason I posted the reply incomplete:

    Here it is

    Private Sub dob_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Calendar6.Visible = True
    Calendar6.SetFocus
    If Not IsNull(dob) Then
    Calendar6.Value = dob.Value

    Else
    Calendar6.Value = Date

    End If
    End Sub


    Private Sub Calendar7_Click()
    dob.Value = Calendar6.Value
    dob.SetFocus
    Calendar6.Visible = True

    End Sub

  4. #4
    Join Date
    Apr 2009
    Posts
    7
    Oh... don't mind the calendar 7.... I forgot to change it to calendar 6

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

Similar Threads

  1. Formating a control in MS Access Reports
    By Alex Motilal in forum Access
    Replies: 3
    Last Post: 11-15-2008, 09:09 PM
  2. Sending control to specific control
    By wasim_sono in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:19 AM
  3. Export Access reports/query results to Outlook Calendar/Task
    By kfinpgh in forum Import/Export Data
    Replies: 0
    Last Post: 02-22-2007, 01:09 PM
  4. clock control in access
    By kfoyil in forum Access
    Replies: 0
    Last Post: 12-02-2006, 01:38 PM
  5. Calendar Mystery
    By BankWalker in forum Forms
    Replies: 0
    Last Post: 02-16-2006, 01:29 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