Solved

error 2455

Posted on 1998-05-26
12
306 Views
Last Modified: 2012-06-27
I have a main form with two subforms (say, subformA and subformB).  The main form only served as a container.  There is a combo box in the subformB.

I put the following statement at subformA's on current event:

me.parent![subformB].form![comboList].requery

And I got the following error message:
------------------------
run-time error '2455':

You entered an expression that has an invalid reference to the property Form/Report.

The property may not exist or may not apply to the object you specified.
--------------------------
What's wrong with the statement?  It seems I can't access the other subform's controls from/within another subform.  I put a command button on the main form and put the following statement on the click event,and it worked:
sub command1_click()
  me![subformB].form![comboList].requery
end sub

Many thanks.

Tasman :(
0
Comment
Question by:tasman082997
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 6

Expert Comment

by:bknouse
ID: 1974445
You can refer to the control with your syntax, but you can NOT do an action (such as requery) UNLESS you first move to that subform.  You could save what control you are on, then move to the subform, do the requery action, and then move back to original subform and finally back to the original control.

Brent
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1974446
What version of Access are you using. I have Access'97 and it worked without any problems...

Try refering without the use of the me object. use forms![Form name]![subformB].form![comboList].requery

I think it should work !
Trygve
0
 
LVL 8

Expert Comment

by:Kobe_Lenjou
ID: 1974447
Trygve has right, the best thing to do is to make an 'absolute' refrence to the other form, you can only use the me.<anything> object if it has the focus I believe. Just don't.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 6

Expert Comment

by:devtha
ID: 1974448
Error code 2455 means..
Invalid reference to property '|'.
I think you should take that parent word out of there..
Devtha
0
 
LVL 12

Accepted Solution

by:
Trygve earned 50 total points
ID: 1974449
devtha: Nice try, but the | character is changed by access according to the problem at hand. If a reference has been made to the form property and this is not valid then | is changed to form -> 'Invalid reference to property form'. If the reference was to the property Caption and this is not valid then 'Invalid reference to property Caption'

The parent property is correct except that the requery method cannot be used from one subform on another subform according to bknouse.

tasman: At this point I make this an answer. If my suggestion proves to be wrong the feel free to reject.
0
 
LVL 6

Expert Comment

by:devtha
ID: 1974450
Tryg: I did not try anything.. All I did was post a comment.
Do not feel unsafe..
Devtha
0
 

Author Comment

by:tasman082997
ID: 1974451
Thank you guys.  I think bknouse was right at the first response.
I tried using forms("MainForm")![subformB].form![comboList].requery; and it didn't work.  Anyway, I changed my form structure and found another way to syn the two subforms.

Thanks again.
Tasman :)

0
 
LVL 12

Expert Comment

by:Trygve
ID: 1974452
devtha: Not to worry, I do not feel unsafe. The term "Nice try" does in fact mean what it sounds like; your attempt at solving the problem was not to bad. The general error messages are always made up like that, with the | character, and I guess that you found the error message without actually reproducing the error. This way you get the general error message. All I did was to make a comment on your comment, explaining how it works.

tasman: First you did not tell us what version of Access you are using. As I wrote I tried in Access'97 without getting any error message.
Second: I was 99% sure that the absolute reference attempt would work. Are you sure that you had the names correct ? Also you might get problems if the second subform is without data  (The table has no data at all or has no data for the linked record in the main form) In these cases any reference to the contents of the subform will produce errors and will have to be delt with in error trapping.
Third: Please tell us how you solved the problem. It might help us understand the problem and/or help others in similar situations.

Have a nice day everyone !
Trygve
0
 

Author Comment

by:tasman082997
ID: 1974453
Hi Trygve,

  Thanks for your response.  Here is the answers for your questions:

1. Access97

2. I was 99.0001% sure I didn't have the typo about the forms' names.  And both subforms had data.

3. Instead of requery a drop down box in another subform directly, I requery the another subform, and have the subform's on current event to requery it's won drop down box.

Is there some update-patch for Access97 that I missed?
Anyway, thanks a lot!

Tasman :)
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1974454
There is always service release 1 for Office. I think I have installed this so this could perhaps explain why I didn't get any error.

It would be interesting to see the error in action. Is it possible for you to send me an extract of your database including the problem form with its subforms and some demo data, or have you removed it for good ? EMail kontry@statoil.no
0
 

Author Comment

by:tasman082997
ID: 1974455
Hi Trygve,
  Thank you for your concern.  I think I have figured out the casue of the problem.

1) A main form with 2 subforms: subformA and subformB.
2) There is a combo box in subformB, say cmbList.
3) On subformA's on current event:
   me.parent.form![subformb].form![cmblist].requery

When the Main form is open, the on_current event of subformA is fired before subformB is ready.  Therefore, there is no reference to subformB's combo box, and casue a runtime error.

Threfore, I force the Main form to load subformB first by:
sub main_onOpen()
  me![subformB].sourceObject = "subformB"
  me![subformA].sourceObject = "subformA"
end sub

It seems it is working now.

Many thanks.

Tasman :)

0
 
LVL 12

Expert Comment

by:Trygve
ID: 1974456
This may just be the cause. Good work ! Still can't figure out why it worked in my app. and not in yours. Your forms may be more complicated, more controls etc. than my simple test forms... hmmmm.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question