Results 1 to 9 of 9
  1. #1
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402

    HTML Color picker form

    Good Morning,


    I have almost comleted my HTML color picker, just a simple form with a group of toggle buttons and text boxes.
    I've yet to add the code to use the selection but that is simple.

    I do have a query about why when i only select up or down the pages work correctly but if i switch between up and down the first key press does nothing and the next key press of the same button works ok and the pages change correctly. If i alternate up / down the page stays the same, have alook and see you can find out why.

    html color picker.zip

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This appears to work:
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Form_Open(Cancel As Integer)
        SetColors (0)
    End Sub
    
    Private Sub down_Click()
        Dim lngMove As Long
        Select Case Me.listcnt
            Case 1
                lngMove = CLng(36)
                Me.listcnt = 2
            Case 2
                lngMove = CLng(72)
                Me.listcnt = 3
            Case 3
                lngMove = CLng(108)
                Me.listcnt = 4
            Case 4
                lngMove = CLng(144)
                Me.listcnt = 5
            Case 5
                lngMove = CLng(180)
                Me.listcnt = 6
            Case 6
                lngMove = CLng(0)
                Me.listcnt = 1
        End Select
        SetColors (lngMove)
    End Sub
    
    Private Sub up_Click()
        Dim lngMove As Long
        Select Case Me.listcnt
            Case 1
                lngMove = CLng(180)
                Me.listcnt = 6
            Case 2
                lngMove = CLng(0)
                Me.listcnt = 1
            Case 3
                lngMove = CLng(36)
                Me.listcnt = 2
            Case 4
                lngMove = CLng(72)
                Me.listcnt = 3
            Case 5
                lngMove = CLng(108)
                Me.listcnt = 4
            Case 6
                lngMove = CLng(144)
                Me.listcnt = 5
        End Select
        SetColors (lngMove)
    End Sub
    
    Sub SetColors(lngMove As Long)
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim i As Integer
        Set db = CurrentDb
        Set rs = db.OpenRecordset("html hex codes", dbOpenDynaset)
        rs.Move lngMove
        For i = 1 To 36
            Controls("toggle" & i).Caption = rs![hex code]
            Controls("toggle" & i).ForeColor = Val("&H" & Mid(rs![hex code], 1, 2)) + Val("&H" & Mid(rs![hex code], 3, 2)) * CLng(256) + Val("&H" & Mid(rs![hex code], 5, 2)) * CLng(65536)
            Controls("text" & i).Value = rs![hex code]
            Controls("text" & i).BackColor = Val("&H" & Mid(rs![hex code], 1, 2)) + Val("&H" & Mid(rs![hex code], 3, 2)) * CLng(256) + Val("&H" & Mid(rs![hex code], 5, 2)) * CLng(65536)
            rs.MoveNext
        Next i
        rs.Close
    End Sub
    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.

  3. #3
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402

    Cool How can I tell the Option group to deselect all buttons

    Thanks for that, I was able to adjust the numbers and get that part to work ok, it has progressed a bit more now. How can I tell the Option group to deselect all buttons, the same as when the form is open there is no selected option.

    html color picker.zip

  4. #4
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402

    Cool How can I convert this to work as a Function

    Ok, sorry for the quick post, I did sort it out and now it all works as I want.
    Now for my next question, how can I convert this to work as a Function, and return My_Value for ForeColor OR the BackColor.

    html color picker.zip

  5. #5
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    P.S. thanks for reworking that bit of code, It does make it neat and tidy. I'll change that as well in the final copy. When donr I'll post a copy in the code repository

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why use radio buttons? They don't act as clean as the toggle buttons.

    Where will you want to use the selected color values?
    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.

  7. #7
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Hi. And thanks for replying, I just picked them as the first one I picked, no reason except that, I cannot change the backcolor of a toggle button. Though thinking about it I should have just used the textbox for each toggle button.

    the 2 values I would like returned are
    My_Value1 "ForeColor"
    and
    My_Value2 "BackColor"

    After clicking the command button "Get_Colors" to open the form, return and put the values into the form fields below
    Me.My_ForeColor
    Me.My_BackColor

    The reason why I asked is, I am planning on using this elsewere in the DB as well.
    P.S. I will also use the code you provided adjust the code as well, thanks.

    Thanks for your help...

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Bizarre. Toggle has a BackColor property. I just tested and it certainly does not work - manual or programmatic.

    Passing values back from a form to a calling form can be tricky. Either the opened form sets value of field on the calling form, or the calling form references textboxes on the opened form. Or set global variables that can be referenced anywhere.
    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.

  9. #9
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Thanks for that, i'll stick with setting values on my master form.
    P.S. just added mouse scroll as well... still building...

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

Similar Threads

  1. color picker for users
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 03-02-2014, 09:36 PM
  2. Microsoft Date And Time Picker on Form
    By ccordner in forum Queries
    Replies: 3
    Last Post: 02-21-2014, 12:35 PM
  3. HTML Controls on Popup Form
    By kelann in forum Forms
    Replies: 4
    Last Post: 11-01-2012, 09:29 AM
  4. Add javascript and html code in form
    By ashu.doc in forum Forms
    Replies: 11
    Last Post: 09-06-2012, 05:20 AM
  5. Export to HTML Button on Form
    By iProRyan in forum Forms
    Replies: 2
    Last Post: 04-26-2012, 11:41 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