Results 1 to 7 of 7
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Form button changes query result

    I have buttons that open a form, I'd like to have each button to change the form's query result.



    So if I click button high school

    the criteria for that query within the form only shows the high schools

    and if I click button primary school

    the criteria for that query within the form only shows the primary schools

    I require the form query to remain blank for when I need to see both - that way I need not make more than one form (it's the same form that opens).

    This is so I can use the same form but have a different query source.

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I'm thinking open form, query field

    Private Sub HighSchoolButton_Click() <<<This being the button
    DoCmd.SetParameter "[SchoolTypeID]=1" <<<This being the query field that is only on the form I am opening, I am not using any values from the form I was on.
    DoCmd.OpenForm "frmSchools" <<<open that form
    End Sub
    doesn't work so far....

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You can do this, and either get the value from the form or hard-code it

    http://www.baldyweb.com/wherecondition.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    You can do this, and either get the value from the form or hard-code it

    http://www.baldyweb.com/wherecondition.htm
    Since I want to customize value in the parameter - do I simply do this?

    DoCmd.OpenForm "SecondFormName", , , "FieldName = #" & 1 & "#"

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    If it's a date.

    "FieldName = 1"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    If it's a date.

    "FieldName = 1"
    Mate. I could kiss you.

    DoCmd.OpenForm "frmSchools", , , "SchoolTypeID = 1 "
    Works

    p.s. I am John Galt

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Quote Originally Posted by Ruegen View Post
    p.s. I am John Galt
    Where's the gulch?!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 04-30-2013, 12:01 AM
  2. Replies: 3
    Last Post: 10-31-2012, 12:14 PM
  3. Replies: 1
    Last Post: 06-09-2012, 05:44 PM
  4. Use query result to open form.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-12-2011, 11:18 PM
  5. HELP! Display a query result into form
    By leanne in forum Forms
    Replies: 15
    Last Post: 06-23-2010, 09:18 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