Error exiting database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wasn't sure in which category to post this question but since the button is
on "form" I'm putting it here. The only code behind the button is:
DoCmd.Exit
I get the error message
The expression On Load you entered as the event property setting produced
the following error: There was a problem referencing a property or method of
an object.
This error message seems to only come up in the compiled .mde version of the
database. Can anyone help with this?
Thanks
 
Does the code really say 'DoCmd.Exit', or was that a typo? If it really says
'DoCmd.Exit', that would certainly cause errors, as the DoCmd object doesn't
have an Exit method. (You probably meant DoCmd.Quit?)

The error message, though, indicates that the problem is in the Load event
of the form, not the Click event of a command button. What does the code in
the Load event look like?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Sorry, yes that was a typo. It's DoCmd.Quit

The Load Event looks like this but I don't understand why it would fire
after the DoCmd.Quit statement. (As you can see, it references some of my
own functions located elsewhere in the project.)

Private Sub Form_Load()

Me.txtWorkstationID = UCase(Environ("USERNAME"))

If UserIsDataEntry Then
Me.cmdMainMenu.Enabled = False
Me.cmdFind.Enabled = True
Else
Me.cmdMainMenu.Enabled = True
Me.cmdFind.Enabled = False
End If

If Not UserIsAdmin And Not UserIsAnalyst Then
Me.cmdCoordinatorAdd.Enabled = False
End If

End Sub
 
Are you using the 'Require Variable Declaration' option? Do you have 'Option
Explicit' at the top of the form's code module? If so, does the code compile
without error if you choose 'Compile <your project name>' form the Debug
menu in the VBA editor?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Yes, I always use Option Explicit. And the project compiles fine. As I
mentioned in my first post, I made it into a .mde as well.

I did create the property for AllowBypassKey in the database. This is
because we're getting ready to move it to production and want to protect the
code, etc. I wonder if that could have caused the problem because (maybe)
AllowBypassKey only applies to "un"compiled databases. It's the first time
I've used this property so I'm not sure if it would have caused a problem
like this.

Thanks again for your reply
 
I think it's unlikely that the problem is with the AllowBypassKey property.
Generally, the things that work in MDBs but not in MDEs are things that
attempt to make design changes to forms, reports, or modules. Other than
examining the code for anything that looks like a design change, I'm not
sure what to advise you. If we could reproduce the problem in an MDB, we'd
get a Debug button in the error message dialog that would show us which line
of code was causing the problem, but if it happens only in the MDE that
makes it more difficult to track it down.

There's also the possibility that the problem might be partial corruption of
the VBA project. If you can't see any code that looks like it might be
trying to make design changes, it might be worth importing everything into a
new, empty MDB and recreating the MDE from that.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top