Why can't I set AllowEdits to false ?

A

acs68

Hi there,

I have set the default AllowEdits property to No in the forms properties. I
then have a button that has the following line of code:

Forms!reqfrmRequests.AllowEdits = True

This line seems to work OK.

If I then try and lock it again by using:

Forms!reqfrmRequests.AllowEdits = False

It doesn't seem to do anything. Does anyone out there know what I am doing
wrong ?

cheers,

Adam
 
D

Dirk Goldgar

acs68 said:
Hi there,

I have set the default AllowEdits property to No in the forms
properties. I then have a button that has the following line of code:

Forms!reqfrmRequests.AllowEdits = True

This line seems to work OK.

If I then try and lock it again by using:

Forms!reqfrmRequests.AllowEdits = False

It doesn't seem to do anything. Does anyone out there know what I am
doing wrong ?

cheers,

Adam

Here's one possibility -- you can't set AllowEdits to False while the
form is dirty. So if you've modified the current record, you have to
either save the record or undo it before you set AllowEdits to False.
 
A

acs68

Thanks Dirk,

you were spot on. Don't suppose you know of a nice way to handle this type
of function ?

cheers,

Adam
 
D

Dirk Goldgar

acs68 said:
Thanks Dirk,

you were spot on. Don't suppose you know of a nice way to handle this
type of function ?

What do you mean, how to force the record to be saved? Either of these
will do it:

If Me.Dirty Then RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False

Note that the former requires that the form currently have the focus,
while the latter does not. On the other hand, if the record can't be
saved for some reason, the latter may give an odd error message about
being "unable to set the property", where the former generally gives a
meaningful error message. That doesn't really matter much if you trap
the error and display your own message.

If I've misunderstood, and you were asking about something else, please
ask in more detail.
 
A

acs68

Sorry Dirk,

I wasn't very clear.

The "If Me.Dirty Then RunCommand acCmdSaveRecord" solved my dilema.

thnaks again,

Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top