Me.AllowEdits = False doesnt work second time

chris-uk-lad

Registered User.
Local time
Today, 01:02
Joined
Jul 8, 2008
Messages
271
Sorry, another question ^^;

I have a form that locks all records on opening (Me.AllowEdits = False on form_load) and use Me.AllowEdits = True when an update or add record button is clicked. However, when i then use a button to complete edits reruns Me.AllowEdits = False it doesnt lock all the fields again.

Any info?
 
I use the OnCourrent event to set me.AllowEdits=False and a button to set me.AllowEdit=true. This way the form in lock on every new record, but may be unlocked by clicking the button. Then when focus is move to a different row, the form is locked again.
 
You have to save the record before you can set allow edits again. Try adding this piece of code just before your Me.AllowEdits = False

If Me.Dirty Then Me.Dirty = False
 
That seems to have solved it :)

Can you explain what the Me.Dirty does? cannot find any true explanations, just examples.
 
Me.Dirty is true if any bound control value on a form has changed, if none has changed Me.Dirty=False.
 
And setting Me.Dirty = False if it is truly dirty means that it forces a save of the record. The same effect can be done with DoCmd.RunCommand acCmdSaveRecord but using that code performs the save operation whether or not anything has changed while the If Me.Dirty line only saves if there is a change, add, or delete.
 
Me.Dirty is used to determine whether or not one or more bound controls of a form have changed. Whether or not that record is saved or some other action is taken is to be taken is another matter.

I commonly use Me.Dirty=true to update an "audit trail" table and other various "stamps" to the dirty table, not to determine whether or not I save the table that is dirty.

One of the benefits of Access, is bound forms. Access does a lot of the dirty record keeping work (pun intended) for the user. My experience is at VB and VB.Net use of unbound forms with ADO is very common.
 

Users who are viewing this thread

Back
Top Bottom