Fred Zuckerman wrote in message
<x55kf.35267$6e1.12843@newssvr14.news.prodigy.co m> :[color=blue]
> I'd like to prevent users from accidently going into design view of a form
> and screwing it up.
> I've googled the group and have found that the normal method is to use MDE
> or user level security. I'd like to avoid both of those options as I'm only
> trying to stop accidental changes, not willful misconduct. These mdb's are
> too quick/simple to over program.
>
> Now, I have found that the following code works, but I'd like to get your
> opinions.
>
> Private Sub Form_Unload(Cancel As Integer)
> On Error Resume Next
> DoCmd.Close
> On Error GoTo 0
> End Sub
>
> I understand that if the user gets the database window, they can open the
> form in design view. That's fine, I'll can live with that. I just want code
> such that if they are changing from datasheet view to form view or back; and
> they accidently click on the "green triangle", the form will just close
> instead of opening in design view.
>
> Any forseeable problems with this?
> TIA
> Fred Zuckerman[/color]
I agree about using mde, but to offer some comments on your approach
I don't know if I can give any good explanations of why, but I don't
like using
docmd.close within a routine where it's alredy closing, don't ask me
why, I
can't give any good reasons - just preference? ;-)
I would suggest qualifying the close, should you use it, i e
DoCmd.Close acForm, me.name
In stead of the above, I'd considered expanding this a bit, using the
approach of having your own close button, in which you toggle a boolean
variable with form class module scope, which will then be assigned the
cancel parameter in the unload event.
See
http://www.mvps.org/access/general/gen0005.htm
for some more info
--
Roy-Vidar