开发者

how to update a recordset in a subform using vb (I am getting error #3426) in Access 2007

开发者 https://www.devze.com 2023-01-06 13:16 出处:网络
I am trying to update a control in a subform. Actually I am calculating the number of months. here is the code: (开发者_运维技巧which doesn\'t work!)

I am trying to update a control in a subform. Actually I am calculating the number of months. here is the code: (开发者_运维技巧which doesn't work!)

 While (Not Me.Form.Recordset.EOF)
months = Round((Me.End - Me.Start) / 30, 0)
Form_FinanceSubform.[number of months] = 0
Me.[number of months] = months
Me.Form.Recordset.MoveNext
Wend

the error i get is: "this action was cancelled by an associated object" on the line Me.Form.Recordset.MoveNext

could someone please help me out here?? thanks!


Just put this part of your code in the form's BeforeUpdate event:

months = Round((Me.End - Me.Start) / 30, 0)
Form_FinanceSubform.[number of months] = 0
Me.[number of months] = months

I do think you could shorten your code to this:

Me.[number of months] = Round((Me.End - Me.Start) / 30, 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号