Results 1 to 12 of 12
  1. #1
    lalit81 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    7

    Multi Item Form checkbox Selection

    I had created a multi item Form with the table as shown having a checkboxes .But If I select the checkbox all other chekcboxes should get clear only one can remain checked at a time. the form is shown below and code as well i dont want to use update query or for loop is there any way


    Code:
    Private Sub chk_Click()
    If chk.Value = -1 Then
    MsgBox (ID)
    Dim s As String
    'MsgBox (chk.name)
    
    
    MsgBox (chk.name & "")
    Dim contr As Control
    For Each contr In Me.Controls
    
    
        If TypeName(contr) = "CheckBox" Then
        
            contr.Value = False
          If contr.name = s Then
                  contr.Value = True
        End If
         End If
    Next
    End If
    End Sub


    Click image for larger version. 

Name:	1590129596102.jpg 
Views:	14 
Size:	99.2 KB 
ID:	42000

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    This is exactly what queries are for.
    like saying I want to get into my house without using any doors.

    the query should set all flags to false,except the current key ID.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Is the check box bound to a field in the form's record source.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    lalit81 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    7
    the query should set all flags to false,except the current key ID. yes certainly not current key Id but the ID against whose checkbox is clicked

  5. #5
    lalit81 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    7
    YES checkbox is bound to the field any idea how to proceed further then

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Code in the AfterUpdate event of the check box to execute an Update query that will change the table field of all records to 0 (false) except the record with the current ID
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    lalit81 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    7
    Dear I already mentioned in the post i dont want to use update query and any LOOP concepts I am looking for other way

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Code required would be something like:
    Code:
    Dim SQL as string
    SQL = "UPDATE Table1 Data2.[YourFieldName]= 0 WHERE (((Table1.ID)<> Me.ID))"
    Currentdb.Execute (SQL)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by lalit81 View Post
    Dear I already mentioned in the post i dont want to use update query and any LOOP concepts I am looking for other way
    What is the objection to using Update query
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    lalit81 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    7
    Dear BOB as i am having huge amount of data n multiusers that's the reason i am not preferring to use a query

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by lalit81 View Post
    Dear BOB as i am having huge amount of data n multiusers that's the reason i am not preferring to use a query
    Sorry, but I don't understand how or why that would make the use of a query objectionable. On the contrary, I should have thought that with a "huge amount", whatever that means, using a query would be the best method.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Your only options for this sort of batch edit are UPDATE query or looping.

    Multiple simultaneous users will likely conflict with each other in editing this field.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 05-01-2019, 12:01 PM
  2. Replies: 4
    Last Post: 03-25-2019, 07:18 AM
  3. Replies: 7
    Last Post: 11-29-2015, 07:24 AM
  4. Replies: 3
    Last Post: 04-10-2015, 10:26 PM
  5. Multi-Item Form, VBA editing on Load?
    By devander in forum Access
    Replies: 3
    Last Post: 08-03-2012, 05:36 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