Results 1 to 11 of 11
  1. #1
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8

    help In Access form - Select and unselect all


    in fact in I have 2 table linked to each other .and i make form and subform for them
    i need help to do the following in the form and subform;
    1- the value of availability is updated based on check box if selected then all availability of current record will be selected. and if not selected all will be unselected .
    2- upon selection from the comboBox in table Data1. the current record (location) value will be copied in the ID of selected combo box record .
    i really need help to do that.

    and i am sorry for my English as it is my second language .
    thanks alot
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    1. right now all records are checked Available - if you want only records associated with the current ID to be checked when checkbox is True then try this code in the checkbox AfterUpdate event:
    CurrentDb.Execute "UPDATE [Data2] SET Availability = " & IIf(Me.Check24 = True, "File_ID=" & Me.File_ID, True)
    Me.Refresh

    2. the combobox is bound to field so this will save selected value to that field and then you want to set value of location field for that ID - could run an UPDATE action in the combobox AfterUpdate event:
    CurrentDb.Execute "UPDATE [Data 1] SET Location = '" & Me.Location & "' WHERE ID = " & Me.Combo21
    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
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8
    Quote Originally Posted by June7 View Post
    1. right now all records are checked Available - if you want only records associated with the current ID to be checked when checkbox is True then try this code in the checkbox AfterUpdate event:
    CurrentDb.Execute "UPDATE [Data2] SET Availability = " & IIf(Me.Check24 = True, "File_ID=" & Me.File_ID, True)
    Me.Refresh

    2. the combobox is bound to field so this will save selected value to that field and then you want to set value of location field for that ID - could run an UPDATE action in the combobox AfterUpdate event:
    CurrentDb.Execute "UPDATE [Data 1] SET Location = '" & Me.Location & "' WHERE ID = " & Me.Combo21

    i tried to do it but it does not work .
    can you help if you can to make in the access database that placed in the attachments to be in the event afterupdate.
    thank you

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Exactly what did you try? What does 'not work' mean - error message, wrong result, nothing happens?

    It's only 3 lines of code, can't get much simpler.
    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
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8
    in fact i did everything but for the :
    1- first code nothing happen , what i need to match the checkbox with the records that linked to the form only to make select and unselect all .
    2- for the second Code ( nothing happen ) : what i need , is once selected from the combobox the number, then the location will placed in the selected combobox record.
    for Example : in the first record , if i select number 12 , then location (MMU) value will be in the record 12 .

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Then post your revised db with attempted code.
    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
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8
    the file zipped and posted.
    Attached Files Attached Files

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    If you want all UNselected then set to False, change checkbox code:

    CurrentDb.Execute "update [Data2] set Availability = " & IIf(Me.Check24 = True, "File_ID=" & Me.File_ID, False)

    Change the combobox code to reference Column 1 by its index.

    CurrentDb.Execute "UPDATE [Data 1] SET Location = '" & Me.Location & "' WHERE ID = " & Me.Combo21.Column(0)
    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
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8
    thanks alot for help ,
    regarding the first code, it is working but affecting all subform record, i need the subform that linked to the parent record to apply to it only , based on the current record .
    so now after i placed the code , once checkebox is false all subform even of other record will be unselected , but once checkbox selected , only current main record subform affected.
    thank you

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Okay, that was my misunderstanding.

    CurrentDb.Execute "UPDATE [Data2] SET Availability = " & Me.Check24 & " WHERE File_ID=" & Me.File_ID
    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.

  11. #11
    majid4ever is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Posts
    8
    thanks alot for amazing help .
    and all code working perfect .
    appreciate your support and help.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-20-2017, 07:04 AM
  2. Replies: 7
    Last Post: 10-04-2017, 09:18 AM
  3. Replies: 9
    Last Post: 01-31-2017, 05:13 PM
  4. Replies: 2
    Last Post: 08-10-2015, 11:53 AM
  5. Unselect listview items in OnCurrent event
    By majq in forum Programming
    Replies: 0
    Last Post: 02-21-2011, 07:51 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