Results 1 to 5 of 5
  1. #1
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86

    Code For Resetting to Default Value

    I have a form with numerous filters on it. When users push a "clear filters" button the following code is executed;

    Private Sub Command71_Click()


    Me.AgentFilter.Value = ""
    Me.SettingFilter.Value = ""
    Me.TransmissionFilter.Value = ""
    Me.InvestigatorFilter.Value = ""
    Me.Requery
    End Sub

    I do have two other filters based on start & end dates that are not included in the "clear filters" button yet because I do not want these filters to go blank, I want them to go back to their default values. Does anyone know what text I use to do this? (i.e. what text goes in Me.StartDate.Value = "????".

    Thank you.

  2. #2
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    Ok, getting the start date to go to my default was easy enough (simply enter that date between the quotes).

    But my default end date is whatever today is and Me.EndDate.Value = "Date()" does not work. Any suggestions?

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by batowl View Post
    I have a form with numerous filters on it. When users push a "clear filters" button the following code is executed;

    Private Sub Command71_Click()
    Me.AgentFilter.Value = ""
    Me.SettingFilter.Value = ""
    Me.TransmissionFilter.Value = ""
    Me.InvestigatorFilter.Value = ""
    Me.Requery
    End Sub

    I do have two other filters based on start & end dates that are not included in the "clear filters" button yet because I do not want these filters to go blank, I want them to go back to their default values. Does anyone know what text I use to do this? (i.e. what text goes in Me.StartDate.Value = "????".

    Thank you.
    AFAIK, only a form has the filter property available. So it sounds like you have some controls (text boxes, combo boxes, list boxes) that you are using as parameters in a query.

    Does the [StartDate] control have the default property set?
    If so, what is the default property set to?

    Also, you don't need to add ".Value" since "Value" is the default property.
    "Me.AgentFilter" is the same as "Me.AgentFilter.Value" and there is less typing

    You should get in the habit of renaming the controls, including buttons, the describe what it is for. "Command71" really doesn't describe what the button does.... I would use something like:

    "Private Sub ClearParameters_Click()"

  4. #4
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    So I was able to handle the start date defaulting to my start date very easily. (Just entered the default date in the quotes).

    But I am still having trouble with the end date. The deafult date for the end date is whatever today is. So in setting up the text box with that default value, I simply entered Date(). But entering that into the code --Me.EndDate.Value = "Date() --- does not work. Suggestions?

  5. #5
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    Ok, answer is to leave quotes of out it, simply Me.EndDate.Value = Date

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

Similar Threads

  1. Resetting Record Source on Form
    By Cheshire101 in forum Programming
    Replies: 5
    Last Post: 05-05-2011, 08:52 AM
  2. Resetting a form having "Required" fields
    By hmushtaq in forum Forms
    Replies: 4
    Last Post: 04-19-2011, 08:24 AM
  3. Resetting Option Group Values
    By oleBucky in forum Forms
    Replies: 4
    Last Post: 03-31-2011, 05:19 PM
  4. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  5. Resetting autonumber when importing
    By bullwinkle55423 in forum Access
    Replies: 3
    Last Post: 06-30-2009, 11:56 AM

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