Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007

    Red face Unanswered: Two Issues: Calendar Control Not Showing Current Date, Validation Issue

    Hi All,

    I am using a calendar control (11.0) in a form. I am using the following code to run the calendar:
    __________________________________________________ ____________________________
    Private Sub ocxCalendar_Click()
    ocxCalendar.Value = Date
    cboOriginator.Value = ocxCalendar.Value
    ocxCalendar.Visible = False
    Set cboOriginator = Nothing
    End Sub
    __________________________________________________ ___________________________

    Option Compare Database
    Option Explicit
    Dim cboOriginator As ComboBox

    Private Sub cboDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Set cboOriginator = cboDate
    ocxCalendar.Visible = True

    If Not IsNull(cboOriginator) Then
    If IsDate(cboOriginator) Then
    ocxCalendar.Value = cboOriginator.Value
    ocxCalendar.Value = Date
    End If
    ocxCalendar.Value = Date
    End If
    End Sub

    When I go to the form to test it, it will not come up with today's date. Can someone tell me what I am missing?

    Also, on the same form users are to enter in some fines into some text boxes. I have a text box for the actual fine total and then after the user enters what the fines were for and their amounts I have a check to make sure that what they entered equals the actual fine. If it does not I have a message box pop up saying it does not match and send them back to the first entry. The validation works fine but, it get's stuck in a loop after the first one and will not let them enter the data after they correct it. Here is the code for that:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim Msg, Style, Title, Response

    If Missort_Fine + Dup_ID + Paid_Early + Priority + COD + Pkg_Type + Unmanifested <> Act_Fine.Value Then

    Msg = "Your Fines Must Equal The Fine Amount!" ' Define message.
    Style = vbOK + vbCritical ' Define buttons.
    Title = "Postal Fine Entry" ' Define title.

    ' Display message.
    Response = MsgBox(Msg, Style, Title)
    If Response = vbOK Then ' User chose Yes.
    Missort_Fine.SetFocus ' Perform some action.
    Cancel = True
    DoCmd.GoToRecord , , acNewRec
    End If
    End If

    End Sub

    I have attached the db as well. Any help that can be given would be great.
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2007
    I found my issue with my error trapping. I am still having issues displaying the current date on the calendar.

    Can anyone out there assist for me?

  3. #3
    Join Date
    Dec 2004
    Madison, WI
    Look at the calendar examples in the Access code bank. They show you how to set the activeX control to the current date in the onLoad event. (ie. me.myCalControlX.value = Date()
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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