Solved

error 2455

Posted on 1998-05-26
12
305 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
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SubReport showing header/footer 3 21
Flowing down data to other tables 13 32
How to set Excel's default SaveAs folder, from Access VBA 6 41
database opened as read only 10 29
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

809 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