Solved

error 2455

Posted on 1998-05-26
12
297 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
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 6

Expert Comment

by:bknouse
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Expert Comment

by:devtha
Comment Utility
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
Comment Utility
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
Comment Utility
Tryg: I did not try anything.. All I did was post a comment.
Do not feel unsafe..
Devtha
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:tasman082997
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now