I have a datasheet (sub)form that receives the recordsource from a stored procedure, so it is not updateable. I want to duplicate one column values - only on Access form - to unbound checkbox (a new column) - so that the user can click it and stuff happens.
I tried setting the value in different ways, but I always get only the value of the first row - inserted to all the rows.
What I receive from stored procedure:
ID | Confirmed |
---|---|
1 | True |
2 | False |
3 | False |
What I want:
ID | Confirmed | ConfirmedCopy (unbound) |
---|---|---|
1 | True | True |
2 | False | False |
3 | False | False |
What I get if I set the Default Value of the ConfirmedCopy to =[Confirmed], or if I do the same with VBA. So it takes the value of the top row and inserts it to all rows in the ConfirmedCopy field:
ID | Confirmed | ConfirmedCopy (unbound) |
---|---|---|
1 | True | True |
2 | False | True |
3 | False | True |
This is the typical behavior of an unbound control in a continuous form. As it is not bound to any field in the record source, it shows the same value in all records of the continuous form.
Solution: fill a local table with the data of your stored procedure. In this table you add also your additional field. Now you can execute a query to fill the field ConfirmedCopy with the data of Confirmed. In your form you set the record source to your local table and now you can do with ConfirmedCopy whatever you want.
After all is done you can clear the local table to be prepared for the next use.
Be aware that this will blow up your database depending on the amount of data you load into the local table. Maybe it is a good advice to compact the database automatically on closing.