Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2009, 04:49 PM
Authorized User
 
Join Date: Jul 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run-Time Error 2465 in Controls syntax

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
 
Old January 18th, 2009, 05:45 PM
Authorized User
 
Join Date: Jan 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forms!frmBookList!fsubSubjectsBook.Form!ID1 is *not* a member of the Controls collection. Only the SubFormControl is.
__________________
HTH RuralGuy (RG for short) aka Allan Bunch MS Access MVP 2007 acXP WinXP Pro
 
Old January 23rd, 2009, 01:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

A few things.

Quote:
Controls("Forms!frmBookList!fsubSubjectsBook.Form! ID" & i).Value = ""
I see a space after the Form! and before the ID. Is that a typo in your post or is that how it actually looks in your code? Remove the space if it's in your code.

RuralGuy points out that the subform's controls are not part of the main form's controls even though the actual subform is a control on the main form. So your code may not work.

To put it in plain English, suppose your main form is a crate and your subform is a carton of eggs. I cannot see the eggs themselves. From the crate's point of view, all I see is a crate (the main form) and the carton (subform). Your code references the eggs. You may get an error message saying, "What eggs? I just see the carton." You have to open the carton and look in to see the eggs. That is, you may have to make the subform active to see its controls and reference them using that particular code.

Another note: setting values to "" is not making them NULL. You're assigning and empty string to all your controls which is actually something.

Do this: MyControl = Null
Not this: MyControl = ""
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old March 1st, 2009, 09:56 PM
Authorized User
 
Join Date: Jan 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You never posted back but I thought I'd give you a stronger hint anyway. Try:

Controls("fsubSubjectsBook.Form!ID" & i).Value = ""
__________________
HTH RuralGuy (RG for short) aka Allan Bunch MS Access MVP 2007 acXP WinXP Pro





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Controls At Run-Time robbev567 ASP.NET 2.0 Basics 2 July 25th, 2007 04:57 AM
Create Controls in Run Time Fredu Access 3 January 8th, 2005 10:03 AM
Copying controls at run time aspadda Excel VBA 0 November 12th, 2003 01:07 PM
Adding controls at run-time !! kishore_peddi C# 0 October 13th, 2003 06:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.