Reputation: 15
Good morning, I am developing an access database for use in Nepali schools. I have a form (the main form) with a subform (frmStudsTakingTTsv2) and 12 textboxes on the subform txtSubA_(i).
I am unable to make a textbox perform a Refresh in VBa . This follows a series of action queries that are working well, these are in an AfterUpdate event on a combo box in the main form. The text boxes are filled from expression builder and so need to be requeryed. The code in there is identical but textboxes on the main form change their contents – so each text box holds a different result.
What I have tried:
A -
frmStudsTakingTTsv2. & "txtSubA_trim(str(i)).Requery
the compiler does not like the &
B – using a string
Where = "Form.frmStudsTakingTTsv2.txtSubA_" & Trim(Str(i))
Me(Where).Requery
Produces run time error 2465 Can not find the field referred to in the expression
C – Then tried this
Dim crtlWhere As Control
Set crtlWhere = frmStudsTakingTTsv2.txtsubA_ & (i)
Me(crtlWhere).Requery
On Load event – method or member not found
D – Next
Set crtlWhere = frmStudsTakingTTsv2
Location = ".txtSubA_" & Trim(Str(i)) – this is fine
Me(crtlWhere & Location).Requery
Error 450 wrong number of arguments
E – Next
Me.Controls(crtlWhere & Location).Requery
Error 450 wrong number of arguments
Just to add this site has been v useful, offering solutions over the years.
Upvotes: 1
Views: 746
Reputation: 55981
Try with:
Me!frmStudsTakingTTsv2.Form.Controls("txtsubA_" & Cstr(i)).Requery
where frmStudsTakingTTsv2
is the name of the subform control.
Upvotes: 0