Solved

error 2455

Posted on 1998-05-26
12
299 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
 
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

17 Experts available now in Live!

Get 1:1 Help Now