Results 1 to 10 of 10
  1. #1
    ortizimo is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Location
    FL
    Posts
    88

    Either/Or Button

    Basically what I need is a button to select one or the other option. Like on and off but when ON is selected if will clear OFF and viceversa. I thought this was what I needed but it won't work.

    Private Sub InCollection_Click()
    If InCollection = True Then
    [Wishlist] = Null
    Else
    If Wishlist = True Then


    [InCollection] = Null
    End Sub

    Thanks.

  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,521
    Have you looked at using a single field, with an option group to select which option?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    This looks like 2 different IFs, but your statement shows 1. Different logic.
    is the [wishlist] a field on a form?
    or did you want to run a query on all records?

    Code:
    If txtInCollection = True Then    txtWishlist = Null
    
    if txtWishlist = True Then txtInCollection = Null

  4. #4
    ortizimo is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Location
    FL
    Posts
    88
    Quote Originally Posted by pbaldy View Post
    Have you looked at using a single field, with an option group to select which option?
    not yet...this is my first time trying something like this and didn't knew there was a group option...thnx.

  5. #5
    ortizimo is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Location
    FL
    Posts
    88
    Quote Originally Posted by ranman256 View Post
    This looks like 2 different IFs, but your statement shows 1. Different logic.
    is the [wishlist] a field on a form?
    or did you want to run a query on all records?

    Code:
    If txtInCollection = True Then    txtWishlist = Null
    
    if txtWishlist = True Then txtInCollection = Null
    yes their both fields on the same form. I'm looking to have the buttons not to accept both at the same time. it has to be either InCollection and not allow the Wishlist to be checked at the same time or the other way.

  6. #6
    ortizimo is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Location
    FL
    Posts
    88
    Ok I did use an option group and it sorts between the two options I want the only issue is that if I click in one option the selected option is NOT checked (checkbox) or highlighted (button) even when the filtering macro does the job. I have to click twice so the option selected reflects on screen. I used the following macro...

    if framStatus=1 then
    ApplyFilter WHERE Condition = Incollection = true
    Else
    if framStatus=2 then
    ApplyFilter WHERE Condition = Wishlist = true
    End Sub

  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,521
    What event is it in? I'd use the after update event of the frame.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    ortizimo is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Location
    FL
    Posts
    88
    Solved it!

    Private Sub InCollection_Click()
    If InCollection.Value = True Then
    Wishlist.Value = False
    Else
    Wishlist.Value = True
    End If
    End Sub

    Private Sub Wishlist_Click()
    If Wishlist.Value = True Then
    InCollection.Value = False
    Else
    InCollection.Value = True
    End If
    End Sub

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For fun, each can be done with a single line, like:

    Wishlist.Value = Not InCollection.Value
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with Paul. Although a little harder to read, I would use
    Code:
    Private Sub InCollection_Click()
        Me.Wishlist = not Me.InCollection
    End Sub
    
    Private Sub Wishlist_Click()
        Me.InCollection = not Me.Wishlist
    End Sub
    I am guessing that Wishlist and InCollection are control on a form...... hence the "Me." ........

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

Similar Threads

  1. Subform Data Entry Button - Search Button
    By thaBadfish in forum Forms
    Replies: 11
    Last Post: 06-23-2015, 03:14 PM
  2. Replies: 9
    Last Post: 03-31-2015, 04:13 PM
  3. Replies: 4
    Last Post: 02-12-2014, 12:49 PM
  4. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 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