简体   繁体   中英

Access subform datasheet using VBA

I currently have a subform which is loaded as a datasheet. So when I click the form, it will display current records (shown below but blurred)

http://imgur.com/n3CNDrv

What I want to do is somehow, in VBA, access the form and it's datasheet to manipulate the cell data. Ie thisform.sheet.cell(1,1) = somevalue

So far I've managed to get access to the form object with Form!Name

You need to create a recordset object, and iterate over the object.

Dim acRS1 as Recordset

You will then need to assign the recordset to the actual table that you want

Set acRS1 = db.OpenRecordset("sometablethatIwanttoupdate",dbOpenDynaset)

You will then need to update the recordset in the manner that you need, which you do not include in your original question.

I will update with the appropriate code when you clarify the exact changes to be made to the recordset (do we want to update a record or add a new record?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM