473,387 Members | 1,515 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,387 software developers and data experts.

Error when closing database if multiple forms are open

Seth Schrock
2,965 Expert 2GB
I'm using Access Runtime 2010 for my users to use my database. frmHome is the name of the form that opens automatically. If I have frmLoans and frmHome open and click the X to close the program, I get an error from frmLoans' OnLoad event saying that "You entered an expression that has an invalid reference to the property Form/Report." (error number 2455). Why is any form's OnLoad event running when I'm closing the database? Should I just trap for error 2455 and resume next for just that error? If I close frmLoans (leaving just frmHome open) and then close the database, then I don't get the error. I also don't get the error with frmLoans open on my laptop that has the full Access 2010 on it.
Apr 5 '13 #1
15 2333
TheSmileyCoder
2,322 Expert Mod 2GB
This sounds very weird and I admit to not having to much experience with using just runtime.

However when something sounds very weird, as is the case here, the first thing to try is to compact&Repair, Decompile, and then recompile.


Now if that doesn't work we would have to look into any events that might run when the form is closed & unloaded, and perhaps it might be relevant to know if you use instanced forms?
Apr 5 '13 #2
Seth Schrock
2,965 Expert 2GB
Neither form has any events related to their closing (OnClose, OnUnload, etc.) I did the decompile, recompile, compact and repair, same error. Not sure what an instanced form is, so chances are I'm not using them.
Apr 5 '13 #3
TheSmileyCoder
2,322 Expert Mod 2GB
If you are using code like:
Expand|Select|Wrap|Line Numbers
  1. Dim oFrm as form
  2. Set oFrm=New Form_Client
Then you are using instanced forms. If you are only opening forms with "Docmd.Open..." then you shouldn't have a problem. Instanced forms is used to open the same form multiple times.

Does your forms recordsource, or any objects on your form reference any fields or controls on other(or same) form?
(For example cascading comboboxes)
Apr 5 '13 #4
Seth Schrock
2,965 Expert 2GB
Then I'm not using instanced forms. I do open frmLoans by selecting a record on frmHome, but then frmLoans doesn't reference anything from frmHome. One thing that I did notice is that when I get the error, it has already closed frmHome, but frmLoans is still open. Not sure if this means anything.
Apr 5 '13 #5
TheSmileyCoder
2,322 Expert Mod 2GB
When frmLoans is opened from frmHome how does it know which record to show?
Apr 5 '13 #6
Seth Schrock
2,965 Expert 2GB
There is a subform on frmLoans that shows a few fields of the query that frmLoans is based on. I double click on one of those records and use the following code.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmLoans"
  2. DoCmd.SearchForRecord "LoanID = " & Me!LoanID
(Me being the subform).
Apr 5 '13 #7
TheSmileyCoder
2,322 Expert Mod 2GB
I must admit to being out of ideas. Can you recreate it on your own pc with full access installed using simulated runtime?
Apr 5 '13 #8
Seth Schrock
2,965 Expert 2GB
If by "simulated runtime" you mean actually using the database as the normal users would, then no I can't recreate the error. No error occurs on my PC while using the full Access.

What could go wrong if I just put the following in frmLoans' OnLoad event error handler?
Expand|Select|Wrap|Line Numbers
  1. If err.Number = 2455 Then Resume Next
Apr 5 '13 #9
TheSmileyCoder
2,322 Expert Mod 2GB
By simulated runtime I mean that the full version of access has the functionality to simulate runtime. If you open access by going to Windows Start and selecting Run and then typing in:
Expand|Select|Wrap|Line Numbers
  1. "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "C:\Test\MyAccessProject.mdb" /runtime
You should be able to simulate the runtime environment as it will look on the users pc. Of course replace the Access executable path and project path as appropriate. I have only used this once myself, so I am not all that familiar with it.


I don't know about ignoring the error. My gut instinct is that the error message you are getting is not related to the "true" cause of the issue. From a testing perspective it might of course be interesting.

If you want, and can, make a sample db and I can try to take a look at it.
Apr 5 '13 #10
Seth Schrock
2,965 Expert 2GB
It does happen when I simulate runtime on my laptop.

I was able to narrow down what the code was that was causing the error in frmLoans' OnLoad event.
Expand|Select|Wrap|Line Numbers
  1. With Me.sfrmEarlyDisclosures.Form
  2.     .AllowAdditions = (TempVars("UserType") <> etLoanOfficer)
  3.     .AllowDeletions = (TempVars("UserType") <> etLoanOfficer)
  4.     .AllowEdits = (TempVars("UserType") <> etLoanOfficer)
  5. End With
It is one of these lines, but I would assume that it is the first as all the others should work if the first one does. However, this code runs fine when I open the form. Do subforms get closed before the main form? Why is the OnLoad event even running when the form closes? I had trouble before with this code (see I get error code 2467 when trying to reference a subform), but that was because I had forgotten to merge the table it was based on to the new backend (SQL Server). Once I did that, the problem went away.
Apr 6 '13 #11
TheSmileyCoder
2,322 Expert Mod 2GB
Interesting. Its nice to hear that it also happens in simulated runtime. That should make it a tad easier for you to debug.

When I have to debug code where the normal debugger is not available to me (For me it might be when something is running in compiled mode, such as a MDE/ACCDE, but I guess runtime qualifies as well.) I usually rely heavily on the msgbox function.

I still feel it is very very odd that this is happening in the onload event, while closing.

So my suggestion would be to try to temporarily change the code to:

Expand|Select|Wrap|Line Numbers
  1. Msgbox "About to run Test of subform reference"
  2. Msgbox "Subform name:" & Me.sfrmEarlyDisclosures.Form.Name
  3.  
  4. Msgbox "ABout to run test of TempVars collection"
  5. Msgbox "UserType:" & TempVars("UserType")
  6. Msgbox "etLoanOfficer:" & etLoanOfficer
  7.  
  8. Msgbox "About to run Test of change to AllowAdditions"
  9. Me.sfrmEarlyDisclosures.Form.AllowAdditions = (TempVars("UserType") <> etLoanOfficer)
  10. Msgbox "Test of change to allowadditions succesfull"
  11.  
With this running you should atleast be able to narrow down where the error occurs. Another method would be to use something like MZ-tools to add line numbering (or do it manually) and then incorporate the line number as part of the error message.

Hope that helps.
Apr 6 '13 #12
Seth Schrock
2,965 Expert 2GB
That is how I narrowed it down to those lines of code. I group the code by setting an integer to incremental values and then pass the value to my custom error message. In this case intCodeGroup got set to 5 on the line prior to my code and gets set to 6 the line after. The number that got returned was 5. TempVars("UserType") was already used in previous code so I know that it works. etLoanOfficer is an enum that I created and it was also used previously successfully.

Anyway, I tried your message box idea to make sure.
Expand|Select|Wrap|Line Numbers
  1. intCodeGroup = 5
  2. MsgBox "SubformName" & Me.sfrmEarlyDisclosures.Form.Name
  3. intCodeGroup = 6
  4.  
  5. With Me.sfrmEarlyDisclosures.Form
  6.     .AllowAdditions = (TempVars("UserType") <> etLoanOfficer)
  7.     .AllowDeletions = (TempVars("UserType") <> etLoanOfficer)
  8.     .AllowEdits = (TempVars("UserType") <> etLoanOfficer)
  9. End With
  10.  
  11. intCodeGroup = 7
Opening the form produced the message box just fine and there were no errors. Leaving that form open when closing the database again caused the error with the code group being 5, so clearly it isn't finding the subform when the database is closing. Is there a way to find out what called the Form_Load event to know why it is running?
Apr 6 '13 #13
Seth Schrock
2,965 Expert 2GB
As this database is going for "live testing" on Monday, I have just tested for error number 2455 in my error handler and removed the With/End With portion so that the error number would be the same for all three lines. This works for now, so I'm good for Monday, but I would still like to know why this is happening and fix the "real" issue. Maybe I can create a sample for you on either Monday or Tuesday.
Apr 6 '13 #14
TheSmileyCoder
2,322 Expert Mod 2GB
This is one of those cases that just sounds so weird, that I get really curious as to what is causing it. If you are using your "code" group number alot I would really recommend taking a look at MZ-tools. Its free for VBA, and it can add/remove line numbers for you by the click of a button. You can get line numbers in your error function by typing ERL.
Apr 7 '13 #15
Seth Schrock
2,965 Expert 2GB
I actually just did download it and I love it! I saw that it had the ERL function, but couldn't find out how to use it. I only use mine when I need to drill down closer to where the error is, but I will probably start using MZ-Tools instead now that I have it.
Apr 7 '13 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Mairhtin O'Feannag | last post by:
Hello, We have two machines we wish to use DPF. They are both RH ES 2.1, with DB2 8.2. I read the documentation CAREFULLY, and added the following line to my db2nodes.cfg file : 1 egret 0
0
by: Mary Lei | last post by:
After instaling db2 8.2.2 on a solaris box I ran a script that drops a database and then creates it. This scripts runs fine under db2 8.2.1 on linux. With 8.2.2 I got a mysterious error about...
2
by: Michael C | last post by:
Hi all, Receiving an error when closing an application that contains the AxWebBrowser component, whenever I close the app: ".NET-BroadcastEventWindow.1.0.5000.0.4: myApplication.exe -...
1
by: chanmm | last post by:
I hit the problem in my WinXP can someone help me: The Web server reported the following error when attempting to create or open the Web project located at the following URL:...
2
by: KCHighland | last post by:
We have an ASP.NET application that permits anonymous access and runs as the IUSR account. The application accesses a SQL Server database located on a different server. All the data access code is...
9
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
4
by: aziz001 | last post by:
I have a form where a person can select how many of a product they want e.g. 1x2g Syringe, 15x100g jar etc. The code will then display string output in a label, listing the products that have a...
21
by: Peter Nurse | last post by:
I have just upgraded to SQL Server 2005 from SQL Server 2000. In Microsoft SQL Server Management Studio, when I click on database properties, I receive the following error:- Cannot resolve the...
11
by: nkechifesie | last post by:
When I run this code to update my database Set AdVehDecp = New ADODB.Connection Set RsVehDecp = New ADODB.Recordset AdVehDecp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=...
3
by: brad atefi | last post by:
I am using the window.open() function to open a music player from my website. It works perfectly in firefox and chrome but ie is giving me an 'object expected' error. Here's my code, and you...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.