Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default value on form control (97)

    Is there an easy way to accomplish the following?

    I have a form that has two dates in unbound controls (txtStartDate and txtEndDate). When it loads the default values are the oldest and newest records in txtStartDate and txtEndDate respectively. In the default properties of the controls I use:
    "=Min([tblMyTable]![I_datInvoiceDate])" and "=Max([tblMyTable]![I_datInvoiceDate]) " for the default values. It works exactly as planned when the form opens. However, I have added a "Reset" control on the form with the goal of being able to reset all the variables to their original default at the click of a button, as opposed to closing the form and reopening it. That was easy for the all the controls that had Null (for combo boxes) and False (for check boxes). The challenge, at least for me, is how to reset the values in the start and end date controls to the min and max date. The following is the code I have for the "On Click" event of the reset button:

    '********Start Code ****************
    Private Sub cmdResetfrm_Rprts_Click()
    Me.cboCompany.Value = Null
    Me.cboLocation.Value = Null
    Me.MinimumCount.Value = 0
    Me.MinimumDollars.Value = 0
    Me.chkIgnoreBlanks.Value = 0
    Me.cboInvoiceNumber.Value = Null
    Me.txtYear.Value = Year(Now())
    Me.Cbo_ExpenseType.Requery
    'Me.txtStartDate.Requery '- No workie
    'Me.txttEndDate.Requery '- No workie
    Me.Requery
    End Sub
    '******** End Code ****************

    Any ideas on how to reset the date controls to the min and max dates from the table? Thanks in advance for your ideas.

    Respectfully,
    Ken

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default value on form control (97)

    Try

    Me.txtStartDate = DMin("I_datInvoiceDate", "tblMyTable")
    Me.txtEndDate = DMax("I_datInvoiceDate", "tblMyTable")

  3. #3
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Default value on form control (97)

    Thank you Hans! Have a great weekend!

Posting Permissions

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