Link to home
Start Free TrialLog in
Avatar of Sengul Topuz
Sengul Topuz

asked on

Continuous form checkbox issue

I have a continuous form where I have a bound checkbox which I want to use for allowing users to select records and press a button to open a form with the selected records. After the second form is open then I clear the checkboxes. The form works perfectly when one user is using it, but when several users are using it does not work properly- different users' selections are mix and matched. How can I solve this problem?
Avatar of Mark Edwards
Mark Edwards
Flag of United States of America image

Sounds like you may be using a bound checkbox (that is being used by all users).  Try replacing the checkbox with a button that opens your form with the selected record's ID (pass record ID with form's OpenArgs property.
Stand back and think about what you are saying.  There is ONE table.  each user is updating rows in that single table to indicate that they should be selected.  How can this ever be kept straight?  If records must be selected one at a time and there is no way to use criteria in a query to select them, then the only way to make the feature support multiple simultaneous users, you MUST store the selected IDs in a separate table and include the UserID in the record so you can tell who selected which records.  Then you would use that table and select the records for the specific user and join back to the original table.  That way UserA will see the records he selected and UserB will see the records he selected.  At some point you will need to delete UserA's records from the selection table.  Would you do this at the beginning of the selection process or after the selections have been used to produce some output.

These are just some of the design questions you need to grapple with before you can resolve this conundrum.
I had someone setting me up this with a checkbox as follows.
Private Sub Command189_Click()
Dim colCheckBox      As New Collection

 If IsChecked(Me.EmployeeID) = False Then
      colCheckBox.add CLng(Me.EmployeeID), CStr(Me.EmployeeID)
   Else
      colCheckBox.Remove (CStr(Me.EmployeeID))
   End If
   Me.Check187.Requery

End Sub
Public Function IsChecked(vID As Variant) As Boolean

   Dim lngID      As Long
   
   IsChecked = False
   
   On Error GoTo exit1
   
   lngID = colCheckBox(CStr(vID))
   If lngID <> 0 Then
      IsChecked = True
   End If
   
exit1:
   
End Function

Open in new window

checkbox = =IsChecked([employeeid])

this worked for multiple users well w/o the need to create extra tables/fields...
I support Pat here.
The code work, according each user retrieve distinct records.
It can't work of records are common to several users.

Your issue is more related to data model design than VBA.
and just to add a bit to the chorus; I do the same technique that Pat mentioned.  I fill a temp table holding the primary key of the main table along with a yes/no field, join this to the main table in a query, and then base the form on that.   The table gets filled in the forms OnOpen.

This way, you end up with a "Select" column on a user by user basis.  

Typically you would want to create the temp table in a temp db, but I find emptying and filling this type of temp table doesn't cause any real database size increase.

Jim.
Avatar of Sengul Topuz
Sengul Topuz

ASKER

Thank you all for the fast responses. I will try your suggestions and report back.
So I was able to successfully implement SelectRecordsV2.accdb into my database and the checkbox works as intended. I have two questions:
1) If you are familiar with the above-referred database you will notice that after each selection of the checkbox there is a flickering in the color and if your speakers are on there is a warning like sound otherwise everything works.  How I can fix this?
2) Is there a short way to read the selected items and create a form with those items? In particular how I can find the selected item IDs and loop? I can do for each and check if the checkbox is checked, but I was wondering if I can apply a query.

Thanks,
"successfully implement SelectRecordsV2.accdb into my database"?  When did "SelectRecordsV2.accdb" come into the issue?  What is it and why "implement SelectRecordsV2.accdb" into your database?

Sounds like an entirely different issue?  Did you answer the right question?
SelectRecordV2.accdb is a sample database which came from one of the examples and it addresses my problem.  I was able to copy the code and implement it on my form. I got the sample database from http://www.ccedv.de/downloads/start.php?download=ButtonArray.zip&lang=en.
I am also uploading it here.
It would be helpful to get an answer to the question#1, I am working and have a good solution for question #2.
SelectRecordsV2.zip
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.