Results 1 to 8 of 8
  1. #1
    jsmm91 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2017
    Location
    Munich, Germany
    Posts
    4

    Question Locking the results of a checkbox

    Hi Everyone

    I am currently working on a project where I exported an access file from a program ( Called Revit), this program is quite tricky to import the information filled in the access file, so it can only write back following exactly the structure as how it exported it.

    in a very specific point, I want to have a checkbox that when is ticked, it will write back a value to a table, and when unticked, it will write another value.
    The checkboxes I created are not linked to any table, they are just placed in the Form.

    I created a small code on VB as On Click even for the Checkbox:

    If (East_Checkbox.Value = True) Then
    East = "-1"
    Else


    East = "1"
    End If

    It works and writes the information without problems.

    The only but is that when I start changing between records, the value stays as the previous way, so if in the previous record it had a tick, in the next one it will also have it, and if in the third one I want to take the tick, it will also remove it in the other two records.

    Click image for larger version. 

Name:	2-01.jpg 
Views:	20 
Size:	65.2 KB 
ID:	29644

    Is there any code I can write so that the value gets saved and do not changed in the next records?

    I tried to paste the same code I wrote in the AfterUpdate but still it does not work.

    Thank you
    Attached Files Attached Files

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Sounds like you want to use the OnCurrent event of the form. Change the names below to reflect your names. Me.North is the bound field on the form that has the values.

    If me.North = 1, then checkboxNorth = True Else checkboxNorth = False
    If me.East = 1, then checkboxEast = True Else checkboxEast = False
    If me.South = 1, then checkboxSouth = True Else checkboxSouth = False
    If me.West = 1, then checkboxWest = True Else checkboxWest = False

    This should set the check boxes depending on the values in the fields on the form.

  3. #3
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    An issue that I see is that you have it doing something in BOTH cases (whether it is checked or not). I think what you really want is a default option that does nothing, and then two options to select that determines which one to be written to. Otherwise, even if you do nothing with the field (and don't click anything), it is going to decide to write it somewhere.

    Or, what you may really want is to NOT have the code that writes the value fire on the Click event of this checkbox. Rather, have it fire on the Update of the record. Then you can freely check/uncheck as you see fit, and it won't update it until the record is updated. You could also add code that will uncheck the box by default as you move from record to record.

  4. #4
    jsmm91 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2017
    Location
    Munich, Germany
    Posts
    4
    Hey Bulzie.

    Thanks for the answer.

    Actually what I want is exactly the opposite.

    If the checkbox North is true, then write in North 1, if false, -1

    I want the checkbox to control the result of the value.

    And most importantly, once it changes, if the checkbox is ticked, if I go to the next Record and it is unticked, that my previous tick will not be unticked.

    What I want is that If the user of the Form places a tick in the checkbox in one of the records, I would like to keep that checkbox intact when moving to the next record. and if data is not written, that the checkbox appears empty.

  5. #5
    jsmm91 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2017
    Location
    Munich, Germany
    Posts
    4
    Hi JoeM

    Thank you for your answer.

    Well, to be honest, if in the form, nothing has been decided, there should not be any information written, also I cannot put any formula in the original table since when bringing it back to the program, it will not allow it since it does not accept changes in the fields, only on the values.

    I think it goes more like what you mention in the second option, that once you move to the next record, it saves the tick but it does not repeat it in the next one, neither when changing the second record, the position of the tick will change on the previous one.

    Could you suggest me how to un-check the box by default once you move to the next record, without the problem that, when returning to the previous one, will erase its value?

    Thank you


    P.S.

    Also, for my values basically I just need -1, 1, and null.

    When I import it to my program(Revit), -1 is yes and 1 is no.

    Null is the position that nothing has been decided yet.

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    The part I wrote is to just have the check boxes values reflect what is in the field values on the form when you move between records. If you then wanted to change a value by clicking or unclicking a check box would be different code.

    But to make it easy, why not just bind the check boxes to those fields and then just display the check boxes, not those fields? Then when they check a box or uncheck it saves the value in the table and will always reflect what the value is in the check box.

  7. #7
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Could you suggest me how to un-check the box by default once you move to the next record, without the problem that, when returning to the previous one, will erase its value?
    Let's say that your check box is named "Check24". Then in the On Current event of the Form, place this code:
    Code:
    Private Sub Form_Current()
        Me.Check24 = False
    End Sub

  8. #8
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Only issue with JoeM code is it will make checkbox Check24 false everytime you move to a new record. Seems to me you want the check boxes to reflect the values in a specific record they relate to is that not so? For instance you move to a record that has North and South as -1 and East and West as blank or 1, then you want only North and South check boxes to show ticked and the other 2 to show blank is that right? Then if you move to next record and it has only West as -1 in the record and other 3 locations are blank or 1, then you only want West to show as checked and the other check boxes blank. Is that logic how you want it to function? This is for just moving through records, you have to still do the code in the OnClick of each checkbox to write the values to the fields.

    Remember that if those check boxes are unbound, then they will not change values automatically unless you provide code in an event to change them.

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

Similar Threads

  1. Locking of the end user app
    By elico in forum Programming
    Replies: 9
    Last Post: 01-27-2016, 02:20 PM
  2. Replies: 1
    Last Post: 11-26-2014, 02:30 PM
  3. Locking down Access
    By snipe in forum Access
    Replies: 6
    Last Post: 05-22-2014, 02:43 PM
  4. Locking Controls
    By fotodj in forum Forms
    Replies: 5
    Last Post: 09-05-2012, 04:45 AM
  5. locking it down
    By BAX5127 in forum Access
    Replies: 0
    Last Post: 03-22-2011, 06:51 PM

Tags for this Thread

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