473,383 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Form Unload/Close Randomness

Hi there,

I am currently working on converting a program from Access 97 to Access
2003. It all worked fine in 97, but there is some randomness in 2003
that I don't understand. I have a form, Main, that loads as follows in
the code:

1. In Main's Form_Load subroutine, the first line calls a routine
(PutTableOnSubform) that will load a data table's fields onto its
subform's (Template) form.
2. PutTableOnSubform's first line opens the subform in hidden mode:
DoCmd.OpenForm "Template", acDesign, , , , acHidden
3. The rest of PutTableOnSubform populates Template with the table's
fields (text boxes) and then the last line closes it up:
DoCmd.Close acForm, "Template", acSaveYes
4. Back in Main's Form_Load, the next chunk of code sets some of the
properties of the Me.subform control, like the source object (Template)
and the caption.

And then the rest of the code runs and the form loads up on the screen
fine.

My problem is, any time after the first time when I press the button to
load Main, I get run-time error 2467, "The expression you entered
refers to an object that is closed or doesn't exist".

When I step through the code on these subsequent loads, the step 2
above calls Main's form_Unload event and then the form_Close event. So
when it goes back to the form_Load event to do step 4 above, it hits
the runtime error entered.

Please tell me if I can supply any additional information in order to
get past this roadblock. Thank you in advance for your help.

Erika

Nov 13 '05 #1
2 2606
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In Access 2002 & higher a form can't be opened in design view when it is
being used as a subform in an open form. The reason it works the 1st
time is the subform's Source Object isn't defined. Perhaps, if you
nulled the subform's Source Object before opening the Template form in
design view, it would work.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQkxAtoechKqOuFEgEQK7wACfUBuEe458En7prtPmVYfsmR YsJDQAn1fw
ikF0IWsK3NqODSTKB2fIamhf
=uXcF
-----END PGP SIGNATURE-----

mi******@gmail.com wrote:
Hi there,

I am currently working on converting a program from Access 97 to Access
2003. It all worked fine in 97, but there is some randomness in 2003
that I don't understand. I have a form, Main, that loads as follows in
the code:

1. In Main's Form_Load subroutine, the first line calls a routine
(PutTableOnSubform) that will load a data table's fields onto its
subform's (Template) form.
2. PutTableOnSubform's first line opens the subform in hidden mode:
DoCmd.OpenForm "Template", acDesign, , , , acHidden
3. The rest of PutTableOnSubform populates Template with the table's
fields (text boxes) and then the last line closes it up:
DoCmd.Close acForm, "Template", acSaveYes
4. Back in Main's Form_Load, the next chunk of code sets some of the
properties of the Me.subform control, like the source object (Template)
and the caption.

And then the rest of the code runs and the form loads up on the screen
fine.

My problem is, any time after the first time when I press the button to
load Main, I get run-time error 2467, "The expression you entered
refers to an object that is closed or doesn't exist".

When I step through the code on these subsequent loads, the step 2
above calls Main's form_Unload event and then the form_Close event. So
when it goes back to the form_Load event to do step 4 above, it hits
the runtime error entered.

Please tell me if I can supply any additional information in order to
get past this roadblock. Thank you in advance for your help.

Erika

Nov 13 '05 #2
Thank you so much!
I put the source object = "" before the puttableonsubform line, and it
loads every time.
Thank you thank you thank you!

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: V.Boomessh | last post by:
Hai can any one help me on this problem. I am new to VB.NET. I have 2 forms. (form1 and form2) On click of a button in form1 i want to show form2 and unload form1
3
by: Mike | last post by:
I recently posted a question regarding a table built using an action query in VBA. I am still having trouble. I have tried saving a record as suggested by one post. The problem A form uses...
19
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the...
4
by: MS | last post by:
Just a general question here re VBA. Can anyone explain the differences between "!" and "." when refering to a control? eg Me!TxtBox and Me.TxtBox. What is difference between "+" and "&"...
4
by: Claudia Fong | last post by:
Hi, I have more than one forms in my program, and I would like to for example, in form1, I will call form2 and in form2 it will call form3. But the problem is when I call form2.Show, it does...
10
by: peter hansen | last post by:
I tried a couple of weeks ago but I'll try again :D I old VB6-days it was possible to unload a form bu using the Unload(Form) command. I have tried the Close-function but it'll unload the entire...
5
by: AP | last post by:
IS there a way to run a procedure if the users close access directly rather than closing a menu screen that I have built? There is an event that works on close for this form, but it doesnt seem to...
4
by: PW | last post by:
Hi, I want to add code to check if the user wants to save the record (fields are unbound) when they press the form's close (X) button. Is it possible to return the user to the form if there...
1
devonknows
by: devonknows | last post by:
Ok, i posted about forcing a form to unload, now since ive implemented that, when check1.value = true, when you close the form, it doesnt unload, when check1.value = false, it unloads perfectly and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.