Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 15th, 2005, 10:18 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default Can't find subform referred to in VBA Error 2450

Okay, I know someone knows this:

I have a module that picks the record PK from a subform, and then works through some queries and totals some dollar amounts, and then returns the total to the subform line, one for each record.

So for example, I have a Project table (main form) and each project can have sub projects (sub form) and each sub project can have itemized labor expenses (sub sub form that opens seperately.) The user enters itemized labor to the sub sub form, and then closes it. The sub form is supposed to then total the itemized labor expenses for each sub project individually. (text box with "=Labor()" module function as control source)

When I open the subform by itself, the module works fine and reports the proper total itemized labor expenses for each sub project.

However, when I open the main form that contains the sub form, I get this error:

"Run-time error '2450':
Microsoft Access can't find the form 'sfrmProjDetail' referred to in a macro expression or Visual Basic code."

I know this should be simple but can't figure out what to do.

Thanks,





mmcdonal
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #2 (permalink)  
Old April 15th, 2005, 02:13 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I believe that no reference to the subform will work until the subform’s initialization has reached a certain point. At the time you are trying to refer to it, it is not yet open for business.

Perhaps you could put a delay in your error handler, and a counter. When the error hits, check the counter value, and if not too many, increment it, run the delay, then Resume.

Perhaps you could put a loop above the point that offends (with on error resume next inside it), continuing to loop till an amount of time has expired, or the subform has become ready to be reasonable (make a reference to it, see if that causes an error; if so, loop).

Brian
Reply With Quote
  #3 (permalink)  
Old April 18th, 2005, 10:05 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I tried practically every event on the sub form, and I think the issue is that if you put the timer on, then it waits for the timer to run and the event to finish until it moves on to the next event, so this is not working.

I also read in Alison Balter that you can set the subform control values from the main form, not the subform. This doesn't work either, but the problem is here that if I set the control source of my text box from the main form, like this: Forms!sfrmMySubForm!txtMyTextBox!ControlSource = "=MyFunction()" then I am essentially editing the sub form in design view, and I am asked to save my changes when I close the main form. I would also have to change the control source of the text box back to "" when I closed the main form so that I wouldn't get the original error the next time I opened the main form.

Anyway, I am thinking I could make a hidden form that opens when the main form opens, waits a few seconds, and then changes the control source for the text box on the sub form. Then I could have the hidden form change the control source back to nothing on the close event of the main form. I still have the "save changes" dialog problem this way, though.

I also tried putting a timer in the function, but that didn't work either.

Any more help? Come on people. :)

mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 2450 gotcha123 Access VBA 0 August 25th, 2008 02:59 PM
Access VBA passing to subform ayazhoda Access VBA 1 July 11th, 2007 07:45 AM
Combine fields>Runtime error 2450 Chris333 Access VBA 4 July 6th, 2007 07:10 AM
run-time error '2450' kk_sg Access VBA 2 August 21st, 2006 10:26 AM
Run-time error '2450' bmurrin Access VBA 6 May 31st, 2006 07:11 AM



All times are GMT -4. The time now is 04:49 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.