Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Location
    California
    Posts
    8

    Unanswered: access 97 calendar default date

    I am working with an access 97 datadase that have a cboStartDate to select
    date from a calendar.

    I need to set up the calendar to the system date.
    I am using the following command:
    ocxCalendar.Value = Date
    But I get an error ("Can't find the field Date")
    If I remove the command. The calendar works, but the date default to the date set on the calendar properties

    Please help me out to solve this problem.

  2. #2
    Join Date
    Sep 2003
    Location
    MN US
    Posts
    313
    I've encountered this before as well. In Acc 2003 I've found if you set the focus to the calendar first, it works.

    So,

    Private Sub Form_Open()

    Me!Calendar0.SetFocus
    Me!Calendar0.Value = Date

    End Sub

    Hope that helps.

  3. #3
    Join Date
    Jun 2004
    Location
    California
    Posts
    8
    I set the focus but it does not work.

    '***********************
    Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' Unhide the calendar and give it the focus
    ocxCalendar.Visible = True
    ocxCalendar.SetFocus
    ' Match calendar date to existing date if present or today's date
    If Not IsNull(cboStartDate) Then
    ocxCalendar.Value = cboStartDate.Value
    Else
    ocxCalendar.Value = Date
    End If
    End Sub
    '********************
    Error I get reads:
    Microsoft access can't find the field Date' rferred to into your expession
    You may have misspelled the field name or the field may have been renamed or deleted.

    Please help

  4. #4
    Join Date
    Sep 2003
    Location
    MN US
    Posts
    313
    Sorry, I don't see anything wrong with your code. Maybe someone else can help you.

    Best of luck.

  5. #5
    Join Date
    Jun 2004
    Posts
    7
    I added a calendar control - ActiveXCtl0 and added the following code into the "Enter" Event Procedure:

    Private Sub ActiveXCtl0_Enter()
    ActiveXCtl0.Today
    End Sub

  6. #6
    Join Date
    Jun 2004
    Posts
    1
    This is probably a bad habit, but it works:

    On open of the Calender for I run this code to set the date to the system date. A simply sendkeys of Ctrl + "t"

    Private Sub Form_Open(Cancel As Integer)

    'Set calender focus to today
    SendKeys "^t"

    End Sub

    I placed a button on the calender that updates the desired feild (In my case my field is DATE_REQUESTED to the calender value and close the form.

    Private Sub SaveAndClose_Click()

    'Set calender focus to DATE_REQUESTED on form
    Forms![frm_Edit]!DATE_REQUESTED = Me.ActiveXCtl0.Value

    DoCmd.Close

    End Sub

    There are many solutions to this problem I think this is the easiest.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •