473,785 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
(PutTableOnSubf orm) that will load a data table's fields onto its
subform's (Template) form.
2. PutTableOnSubfo rm's first line opens the subform in hidden mode:
DoCmd.OpenForm "Template", acDesign, , , , acHidden
3. The rest of PutTableOnSubfo rm 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 2626
-----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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQkxAtoechKq OuFEgEQK7wACfUB uEe458En7prtPmV YfsmRYsJDQAn1fw
ikF0IWsK3NqODST KB2fIamhf
=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
(PutTableOnSubf orm) that will load a data table's fields onto its
subform's (Template) form.
2. PutTableOnSubfo rm's first line opens the subform in hidden mode:
DoCmd.OpenForm "Template", acDesign, , , , acHidden
3. The rest of PutTableOnSubfo rm 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 puttableonsubfo rm 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
1950
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
3935
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 the new table as its recordsource. However, even when the form is closed using either the close button on the form title bar or using the docmd.close the form fails to release its connection to the table making it locked and unable to be dropped or...
19
3611
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 thing you know ;-) After discovering that access 2000 support form properties (I'm a
4
3710
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 "&" when working with strings. eg MyStr = "I have " & MyNumber & " apples." and MyStr = "I have " + MyNumber + " apples."
4
21542
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 show the form2, but how can I unload form1? If I put form1.close, it will close everything. :(
10
1749
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 projekt. The reason why I am asking is that I am creating a program and I need a Splash-screen (like the tiny screen that appears when programs like Word starts), and when the Splash-screen has been loaded for a couple of seconds it should be...
5
7448
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 run if the form is open and the suer just closes access all together, is there a way around this? Thanks
4
13112
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 are editing errors? I am using Access 2003
1
1669
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 does all the ADO with it, but when check1.value = true its doing the ADO commands, but just not unloading, if anyone can shed some light would be most greatful. Kind Regards Devon. Module code. Option Explicit Public g_fmrSearch As...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.