最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ms access - VBA Duplicate column value to an unbound field - Stack Overflow

programmeradmin0浏览0评论

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
Share Improve this question edited Jan 21 at 11:21 sasos asked Jan 21 at 11:11 sasossasos 256 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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.

发布评论

评论列表(0)

  1. 暂无评论