admin管理员组文章数量:1318569
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 |
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 |
1 Answer
Reset to default 3This 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.
本文标签: ms accessVBA Duplicate column value to an unbound fieldStack Overflow
版权声明:本文标题:ms access - VBA Duplicate column value to an unbound field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047068a2417849.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论