By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,688 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,688 IT Pros & Developers. It's quick & easy.

Form suddenly won't open, why?

P: n/a

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
Share this Question
Share on Google+
4 Replies

P: n/a
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

P: n/a
>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

P: n/a
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

P: n/a
>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 discussion thread is closed

Replies have been disabled for this discussion.