Run-Time Error 2465 in Controls syntax

ybg1

Registered User.
Local time
Today, 02:28
Joined
Jan 3, 2009
Messages
20
The following routine resets 36 Text Boxes in array:
For i = 1 to 36
Controls("ID" & i).Value = ""
Next i
It works fine.
--------------------
With the following code I get a Run-Time Error 2465
that it can't find the Field ID1

For i = 1 to 36
Controls("Forms!frmBookList!fsubSubjectsBook.Form!ID" & i).Value = ""
Next i
---------------------
I've tried to reset this value without using Controls and it does work ok.

Forms!frmBookList!fsubSubjectsBook.Form!ID1 = ""

It seems to be as with the Controls syntax it dosn't work.
-------------------------------------------------------
Later in the program I fill up the boxes with values from the database so I
cannot do it one by one 36 times.

Any Idea how to get over this problem ?

Thanks
 
I'm not too good with syntax. Looks like you're using a subform? If so, maybe this:


Dim f as form, txt as TextBox
set f = Forms!frmBookList!fsubSubjectsBook.Form
Set txt = f.Controls("ID" & i)
txt.Value = ""
 
Hi there,

Access help says:

You can also refer to an individual control by referring explicitly to the Controls collection.
Me.Controls!NewData ' Or Forms!OrderForm.Controls!NewData.

So if you change it to

Code:
Forms!frmBookList!fsubSubjectsBook.Controls("ID" & i).Value = ""

it should work
 

Users who are viewing this thread

Back
Top Bottom