473,509 Members | 3,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form suddenly won't open, why?


I am working in Windows 2000 and Access 2000 and am a rookie in Access.

Coding merrily along, I stop periodically to test that everything works.

After adding a small amount of code to several events, when I try to run the
form suddenly won't run. I get the message "The expression On Open you entered
as the event property setting produced the following error: Constant Expression
Required."

Two possible reasons follow on the screen:

1. The expression may not result in a macro, the name of a user-defined
function, or [Event Procedure]
2. There may have been an error evaluating the function, event, or macro

Between the last time it ran and now, I had added the following code to a
button click event on my form.

Dim strPath As String
Open (strPath & "tra.txt") For Output As #1
gm_rc = 0
For indx1 = 0 To cm - 1 ' incremented but NOT redimensioned
For indx2 = 0 To im(indx1)
Write #1, rc(indx1, indx2)
Next indx2
If im(indx1) > gm_rc Then gm_rc = im(indx1)
Next indx1
Close #1

I suspected this was the "Open" event causing the trouble except:

(3) The error occurs if I comment out this code
(4) The error occurs before the form opens and the button click event can't
occur (can it?)
(5) The error occurs if I comment out every statement in the Form On Open event
(6) The error does NOT occur if I completely eliminate the Form On Open event
completely from the VB code
(7) If I reinsert a blank On Open event, the error reappears

The other "major" change I made since things ran right was in the Form On Open
event code. I added code to get the path to the current database:

strPath = CurrentDb.Name
tmpIndex = InStr(1, strPath, "filename.mdb", vbTextCompare)
If tmpIndex > 0 Then
strPath = Left(strPath, tmpIndex - 1)
Else
MsgBox ("Problem locating folder for reading/writing temporary files. Default
to C:\")
strPath = "C:\"
End If

strPath is dimensioned as a string (global variable)
tmpIndex is dimensioned as an Integer (local variable)

This, and all the rest of the VB code for the Form_Open event, is visible in
the VB Code Editor. The other changes involved initalizing variables. I can't
think of anything I , intentionally, changed that would cause this behavior.

I didn't mean to make any other changes, but must have. I ran the Compact and
Repair Utility with no success. Does anyone know what I did and how to fix it?

Thanks,

Paul Core
Nov 12 '05 #1
4 7086
On 02 Jan 2004 23:51:02 GMT, co******@aol.combvwertz (Corepaul) wrote:

I am working in Windows 2000 and Access 2000 and am a rookie in Access.

Coding merrily along, I stop periodically to test that everything works.
A good practice. I recommend changing that to to frequently, bordering on
constantly.
After adding a small amount of code to several events, when I try to run the
form suddenly won't run. I get the message "The expression On Open you entered
as the event property setting produced the following error: Constant Expression
Required."

Two possible reasons follow on the screen:

1. The expression may not result in a macro, the name of a user-defined
function, or [Event Procedure]
2. There may have been an error evaluating the function, event, or macro


The cause will be one of 3 things:
1. The event property in the control itself is corrupted. Try deleting the
property in the property sheet, and picking it again from the drop-down list.
2. The signature of the event procedure is messed up. The even must have the
correct parameter names and types (or lack thereof) that the event signature
expects. The best way to fix this if it's messed up is to copy out the body
of the procedure, delete the procedure entirely (not just the body), and let
Access create it again by clicking the ... button next to the property in the
sheet. Finally, paste the code body back into the procedure (without copying
over the new Private Sub ... line).
3. Your form is simply corrupted (not terribly uncommon). You may have to
manually recreate the form.

Nov 12 '05 #2
>Subject: Re: Form suddenly won't open, why?
From: Steve Jorgensen no****@nospam.nospam
Date: 1/2/2004 6:38 PM Central Standard Time
Message-id: <jm********************************@4ax.com>
I tried your first two suggestions with no success so it must be...
3. Your form is simply corrupted (not terribly uncommon). You may have to
manually recreate the form.


Luckily I keep backup copies as I work. I reloaded the backup, made my changes
and everything works fine.

If corruption is not uncommon, do you know what causes it? I am trying to
understand the cause so that I can avoid it in the future. I swear I didn't
intentionally do anything weird.

Thanks for the help.

Paul Core

Nov 12 '05 #3
On 03 Jan 2004 19:39:45 GMT, co******@aol.combvwertz (Corepaul) wrote:
Subject: Re: Form suddenly won't open, why?
From: Steve Jorgensen no****@nospam.nospam
Date: 1/2/2004 6:38 PM Central Standard Time
Message-id: <jm********************************@4ax.com>


I tried your first two suggestions with no success so it must be...
3. Your form is simply corrupted (not terribly uncommon). You may have to
manually recreate the form.


Luckily I keep backup copies as I work. I reloaded the backup, made my changes
and everything works fine.

If corruption is not uncommon, do you know what causes it? I am trying to
understand the cause so that I can avoid it in the future. I swear I didn't
intentionally do anything weird.

Thanks for the help.

Paul Core


No matter how careful you are, Access is prone to occasional corruption when
you make design changes. The main thing to watch out for is to turn off Name
Autocorrect in the options for each new database you create. That "feature"
has some serious issues.
Nov 12 '05 #4
>From: Steve Jorgensen no****@nospam.nospam
Date: 1/3/2004 9:20 PM Central Standard Time No matter how careful you are, Access is prone to occasional corruption when
you make design changes. The main thing to watch out for is to turn off Name
Autocorrect in the options for each new database you create. That "feature"
has some serious issues.


I checked and did have the Name Autocorrect feature selected. It's off now.

Thanks for the tip!

Paul Core
Nov 12 '05 #5

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

Similar topics

11
5932
by: SELIM ZAIRI | last post by:
hi, to all i was wondering if some one got this problem before and if he had any solution i got a query: SELECT MSysObjects.Name, MSysObjects.Type, GETFRMCAPTION() AS Expr1 FROM MSysObjects...
19
3585
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...
8
1760
by: Emily Jones | last post by:
Very strange one this. Application written in Access 2000. Runs in 2003 at client's site, 2000 on my development system. FE/BE system. The app's startup form sets a few options, opens the...
12
1715
by: melanieab | last post by:
Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type...
2
1117
by: IT Drone | last post by:
I'm running Windows Server 2003, IIS 6.0, and VS 2003. I have an ASP.NET project I previously created, and went to open it back up to make modifications. Now VS won't open http://localhost ...
3
1340
by: Tim | last post by:
Hi, I have have a program containing two forms that are open at the same time. The main form updates the second when the user enters input by adding a control to it. My problem is that when the...
19
4621
by: rbrowning1958 | last post by:
Hello, I am confused by dispose etc. and hope someone can set me right. 1. The Dispose(Bool) the IDE generates for a form has nothing to do with IDisposable, right? 2. So when is this called?...
2
4014
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded =...
9
3333
GazMathias
by: GazMathias | last post by:
Hi Guys, Acc2003. I have a form that is misbehaving by suddenly refusing to apply a filter I am passing to it. In a nutshell, I use a public variable to control the form's behaviour called...
0
7136
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...
0
7412
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...
1
7069
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...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1570
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 ...
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.