Results 1 to 15 of 15
  1. #1
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139

    Replace option buttons in an Option Group with a picture


    Is it possible to use an image, in place of a radio button in an Option Group. I want to add a 5 star rating type of setup on a form for a movie database. I would like a group of 5 grey scale stars in place of radio buttons or option buttons. When clicked, I'd like the star to turn Gold colored and enter the option 1, 2, 3, 4, or 5 into the table. Is this possible?

    Thank you for your help!
    Michael

  2. #2
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Ok, I figured out the first part. I now have the grey scale stars where the buttons were. Now, how to replace the grey scale star with a gold one.

    Thank you!

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    How did you substitute button with star?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by June7 View Post
    How did you substitute button with star?
    I just set the picture property in the property sheet for each toggle button.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Oh, used toggle button instead of radio button.
    So now code could change Picture property when button is clicked. Have a grey star image and a gold start image.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Sounds interesting. Choose star 3, then pass 3 to a function that toggles on each one that is less than or equal to 3! You should then be able to sum the abs values of the toggles in that function.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by June7 View Post
    Oh, used toggle button instead of radio button.
    So now code could change Picture property when button is clicked. Have a grey star image and a gold start image.
    I have both pictures, what should the code look like to change the pic?

    Thank you!

  8. #8
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by Micron View Post
    Sounds interesting. Choose star 3, then pass 3 to a function that toggles on each one that is less than or equal to 3! You should then be able to sum the abs values of the toggles in that function.
    Whoa, totally lost me there.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    5 Toggles within a frame will have values of 1 to 5, not 0 or -1.

    The Frame will take value of whichever toggle is down. Frame bound to field will save that value. Only one toggle can be down (highlighted).

    Is this what you want?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by June7 View Post
    5 Toggles within a frame will have values of 1 to 5, not 0 or -1.

    The Frame will take value of whichever toggle is down. Frame bound to field will save that value. Only one toggle can be down (highlighted).

    Is this what you want?
    Yes, only one toggle will be down.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Name the toggles like tgl1, tgl2, etc.
    Code:
    Private Sub Frame158_Click()
    Dim x As Integer
    For x = 1 To 5
        Me("tgl" & x).Picture = IIf(x = Me.Frame158, "gold image path", "grey image path")
    Next
    End Sub
    
    Can get this to work only with bmp image.

    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by June7 View Post
    Name the toggles like tgl1, tgl2, etc.
    Code:
    Private Sub Frame158_Click()
    Dim x As Integer
    For x = 1 To 5
        Me("tgl" & x).Picture = IIf(x = Me.Frame158, "gold image path", "grey image path")
    Next
    End Sub
    
    Can get this to work only with bmp image.

    Ok, this worked while the Form is opened and passed the value to the table but when I move from one record in the table to another, the position of the Gold star is the same on each record and if I close the form and reopen it again, the stars are all grey again. Can I get the "Rating" value from the table and make the star in that position to appear gold?

    Thank you!

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Run the same code in form Current event. Could put into a Sub that can be called by Frame Click event as well as form Current event.

    All records will show the same star so doesn't really work for continuous or datasheet form.

    Consider an approach that uses image controls. An expression in ControlSource can conditionally select image based on field value. So every record will display appropriate image. Use image control Click event to save value to field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    No need of frame.
    You may use images with full stars , with a conditional ControlSource to the file path of the "empty star" and transparent buttons over them for changing the rating value of each record.


    If you have an image for the "empty star" in the same place with your project, a public function like below could simplify the expression of ContolSource.
    Code:
    Public Function EmptyStar() As String
        EmptyStar = CurrentProject.Path & "\EmptyStar.png"
    End Function
    So we have:
    - ControlSource of image "Star 2" : =IIf([ratValue]<2;EmptyStar())
    - OnClick event of button 2: Me.ratValue = 2

    and so on for the rest of the stars.

    Take a look in attached sample.
    Attached Files Attached Files

  15. #15
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Quote Originally Posted by MichaelA View Post
    Whoa, totally lost me there.
    Think of it as operating like a web page where you click star 4 and all the lower ones are chosen also. You would not expect to have to click 4 stars to give a 4 star rating, right? So I'm saying loop through the controls and select all that are equal to or less than the one you chose. However, it looks different that what else has been suggested if you use toggle buttons.
    Click image for larger version. 

Name:	starRating.jpg 
Views:	10 
Size:	4.8 KB 
ID:	42280
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Option Group Hide buttons VBA codes
    By JennyL in forum Access
    Replies: 3
    Last Post: 01-13-2017, 05:12 PM
  2. Option group radio buttons
    By sharonir22 in forum Forms
    Replies: 3
    Last Post: 07-04-2015, 11:11 PM
  3. Radio buttons within Option Group not working
    By losingmymind in forum Programming
    Replies: 7
    Last Post: 01-09-2013, 03:09 PM
  4. Use of option group buttons
    By sireesha in forum Forms
    Replies: 1
    Last Post: 10-25-2012, 01:20 PM
  5. option group radio buttons
    By ManC in forum Forms
    Replies: 9
    Last Post: 03-08-2010, 03:46 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