Solved

error 2455

Posted on 1998-05-26
12
311 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

705 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