Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Resetting check boxes

    Trying to rest 3 checkboxs in a frame to unchecked. Have drafted a simple Function to test if I can but keep getting the message " You can't assign a value to this object.

    The code in my test is called by clicking a button on the form when I figure out how to do it I will call it as the next (new) record loads.


    Private Sub Command9_Click()
    testStatusCheckBox

    End Sub


    Function testStatusCheckBox()
    Dim ctl As Control

    For Each ctl In Forms!form1!Frame0.Controls
    If Not (ctl.ControlType = acLabel) Then
    If ctl.ControlType = acCheckBox Then
    ctl.Value = False
    End If
    End If
    Next ctl
    End Function

    Thanks

    Peter

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Peter,

    I think the problem lies in the fact that you are using a Frame. When I generated a frame with 3 check boxes and tried to run code to clear it generated the same error you received because the first check box was not selected. If however I put the 3 check boxes in a rectangle vs frame the code works as expected. It has something to do with the frame only allowing one selection not multiples. I haven't tried it yet w/o using the wizard which may generate a different object.
    Access Clear checkboxes.JPG
    HTH

    Update: You may find this Microsoft Article helpful.
    Last edited by RetiredGeek; 2013-06-30 at 16:55.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mitchbvi (2013-06-30)

  4. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hi

    And thanks a lot for your suggestion, I just figured it out I think, I need to set the frame rather than the checkboxes to Null and that does the job. Now to get it into the rest of the code without wrecking something else.

    Peter

  5. #4
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    That did not work in the real world, on my test form I was using a button to set the frame to Null. In my actual document I cannot use a button and have tried to write the Null into subsequent steps and that does not do anything. By the way I cannot use a rectangle box as the three checkboxes are use in a select statement so only one can be active.

    Back to the drawing board, thanks again.

    Peter

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Peter,

    I've found that this will work as code for a button.
    Code:
    Private Sub cmdClearFrame_Click()
    
       Me.frameCkBoxes = Null
    
    End Sub
    Note: If you have set a default value setting the frame to Null will redisplay the default value. If you do not have a default value it will set all check boxes to a solid color.
    Access Clear checkboxes.JPG
    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mitchbvi (2013-07-01)

  8. #6
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Thanks again, that is how I got it to work on my test from also using the double click event works. Adding a button means a number of other adjustments to the form and looks awkward so I am still searching for a way to program it as I exit the frame. On exit event does not work tried that.

    Take care

    Peter

  9. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Peter,

    Try the LostFocus Event it may work for you. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mitchbvi (2013-07-01)

  11. #8
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    The Frame does not have a lost focus event (I am using Access 2003) the check boxes do and in my test form that worked. the problem is that after exiting the frame the control it goes to next is based on a select case the values for which are driven by the box checked in the frame so I cannot change the value/selection in the frame until after that has happened which precludes the use of lost focus.

    Thanks again this is proving to be a battle.

    Peter

  12. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    You could use the On Double Click of the frame to do this

  13. The Following User Says Thank You to patt For This Useful Post:

    mitchbvi (2013-07-02)

  14. #10
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Thanks Patt

    As I mentioned a couple of posts back I had discovered the double click works but I could achieve the same by setting up the click event on the frame itself both require operator input and I am trying to do it programatically.

    Putting a button on the form setting the focus to it then an on exit event is close but clumsy.

    Peter

  15. #11
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    Sorry I missed that, can you do it on the afterupdate event of the frame?

  16. The Following User Says Thank You to patt For This Useful Post:

    mitchbvi (2013-07-02)

  17. #12
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Patt

    Cannot do that as I need the value for a step after the frame is updated as I said earlier. I did try setting a different variable to the value from the frame and if I remember correctly Access will not let me change the value set in the frame certainly on exit and I guess therefore on after update.

    For anyone that is interested avery clumsy workaround that I am working on is.

    Set up a button hide it behind the frame (cannot set its property to invisible as I need to set it with the focus). After my calculation is done move the focus to the button and set the exit event to Frame0=Null. This is working on my testDB not yet implemented in the real world.

    Thanks again

  18. #13
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    Well I tried it in the after update of the frame and it works (I also tried it on the onexit event and it works there too.
    What you could do is save the value in an invisible text box on the form before clearing the frame.

  19. The Following User Says Thank You to patt For This Useful Post:

    mitchbvi (2013-07-03)

  20. #14
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Vail, Colorado, USA
    Posts
    194
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Patt

    Thanks, that works in my test model and a lot simpler than my idea, now to make sure it works in the real world.

    take care

    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •