Results 1 to 14 of 14
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479

    Checxk Box Control source

    This looked like an answer I need
    https://www.access-programmers.co.uk...y-fill.275306/

    But my checkbox has no control source property. I tries Me.Check2.controlSource = 0 in Form Load but that had no effect.
    Likewise Me.Check2.DefaultValue = ( tried -1, 0, and 1). All did nothing.

    The Checkbox is unbound and just for display. How can have a tick showing?


    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Did you place checkbox within an option group control? If it is, it won't have ControlSource property.

    Checkbox must be independent to have ControlSource property.
    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
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Yes I did June. Does this mean it can't be ticked or unticked with VBA code ?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Correct. The OptionGroup control has ControlSource property. Set it.

    Why an OptionGroup anyway?
    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.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Click image for larger version. 

Name:	chk.png 
Views:	22 
Size:	1.3 KB 
ID:	51903

    Checkboxes in an option group are a very different animal than standalone checkboxes. Those in an option frame are referred via the option frame's index. The index indicates which control within the option group is selected. In the example, there is only one checkbox so the only values possible for the option frame is 0 (nothing selected) and 1. The code simply toggles the option frame value between 0 and 1. The frame needs a default value of either 1 or 0, depending on which is desirable when form is loaded.


    A standalone checkbox does have a value; true or false. The code for chk2 toggles true and false for the click event.


    Code:
    Private Sub chk1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Me.Frame8.Value = 0 Then
            Me.Frame8.Value = 1
        Else
            Me.Frame8.Value = 0
        End If
    End Sub
    
    
    Private Sub Chk2_Click()
        chk2.Value = Not chk2.Value
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can have multiple checkboxes within Option Group although the usual arrangement is with radio buttons.

    Can also have toggle buttons in a Group. The advantage is they are bigger than checkboxes and radio buttons.
    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
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    I wanted to have a border around a bunch of controls for visual affect. I used an option Group as I couldn't find another frame control.
    Could I have used something else?
    Dave has put me right and now I have the check button working.
    Instead of
    Me.Check2.Value = False
    its
    Me.Frame0.Value = 0
    No mouse action is needed as its a on/off type of display.
    Vague memories about addressing via a Frame... but the text boxes didn't need it so it never occurred to me.
    Thanks !!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can use a rectangle control set transparent. Order it behind other controls.

    "its a on/off type of display" - what triggers on/off?

    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
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Thanks June, I've changed to the rectangle.
    Is that a bit like a Panel in VB ?
    The check indicates whether a file exists or not.

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If you need the frame caption that a group frame has, add a label over your rectangle in the same position and make its background solid, and perhaps its colour to match the form background.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, so how do you know a file exists?
    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
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Quote Originally Posted by June7 View Post
    Okay, so how do you know a file exists?
    Code:
    Function fileExists(s_path As String) As Boolean
        Dim obj_fso As Object
        Set obj_fso = CreateObject("Scripting.FileSystemObject")
        fileExists = obj_fso.fileExists(s_path)
        Set obj_fso = Nothing
    End Function

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So expression in checkbox Control Source:

    =fileExists(reference textbox that has filename)

    Don't even need FSO. Function can use:

    fileExists = IIf(Dir(s_path) <> "", True, False)
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    Don’t even need that

    fileExists = Dir(s_path) <> ""

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

Similar Threads

  1. Replies: 4
    Last Post: 04-26-2020, 02:33 AM
  2. Replies: 19
    Last Post: 06-26-2018, 07:13 AM
  3. Replies: 3
    Last Post: 04-27-2016, 01:25 PM
  4. Replies: 4
    Last Post: 02-18-2016, 12:06 PM
  5. Replies: 5
    Last Post: 09-18-2013, 09:15 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