Results 1 to 5 of 5
  1. #1
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102

    Question Make a button open different forms depending of the value of a combo box.

    Self explanatory.
    I tried the "If" command but, again, I just don't quite get it.

    Private Sub Command52_Click()
    If GraphShow Is "First" Then
    DoCmd.OpenForm "FRMGraphFirst"
    Else


    DoCmd.OpenForm "FRMGraphsTest"
    End If
    End Sub

    "GraphShow" is the combo box.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    If Me.GraphShow = "First" Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Quote Originally Posted by pbaldy View Post
    Try

    If Me.GraphShow = "First" Then
    There, thanks.
    I just didn't know the preffix.

  4. #4
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Oh boy, now what if I want more than 2 choices?

    Code:
    Private Sub Command52_Click()
    If Me.GraphShow = "First" Then
    DoCmd.OpenForm "FRMGraphFirst"
    If Me.GraphShow = "Second" Then
    DoCmd.OpenForm "FRMGraphSecond"
    Else
    DoCmd.OpenForm "FRMGraphsTest"
    End If
    End Sub
    Is there such a thing as Else if?

    EDIT: Yes there is... ElseIf (one word).
    I need to forget C++ in this, man.

  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,652
    ElseIf will work, there's also Select/Case which is good for multiple options.
    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. Form with Combo Box and Button to Open
    By MarkV in forum Forms
    Replies: 6
    Last Post: 02-01-2016, 03:24 PM
  2. Open form make combo box select year
    By Ruegen in forum Forms
    Replies: 12
    Last Post: 03-27-2014, 10:32 PM
  3. Replies: 6
    Last Post: 10-11-2012, 02:19 PM
  4. Replies: 3
    Last Post: 09-06-2012, 11:01 AM
  5. HOW TO: Button to open different forms?
    By Natan in forum Programming
    Replies: 5
    Last Post: 08-01-2011, 01:58 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