[AccessD] Dirty Cancel Clear all controls

Bill Benson bensonforums at gmail.com
Tue Feb 13 17:37:29 CST 2018


My understanding is that Me.Dirty = False saves the current record. That is
what is being done in this database I am currently working in, the code is
sitting there with that exact comment:


    'Save the change made to the forms (ie., Scenario change)
    Me.Dirty = False


On Tue, Feb 13, 2018 at 3:35 PM, Jim Dettman <jimdettman at verizon.net> wrote:

> Bob,
>
>    A couple things:
>
>   Me.Dirty = False is equivalent to Me.Undo for the record and you will be
> back to default values.
>
>  The alternative is Me.Undo, but the catch there is you may need two; one
> for the control (if it's dirty) and then one for the record.   Most use
> Me.Dirty = False because it covers everything. You only need one or the
> other.
>
>  You can't clear controls like this as not everything can be modified (i.e.
> an autonumber).   I would either:
>
> 1. check the field type it's bound to
> 2. rely on the enabled field (assuming everything you want cleared is
> enabled).
> 3. Use a tag in the control Tag property if it should be cleared or not.
>
>  With that said though, you usually want new records to be at their
> defaults.   If you don't, then maybe you want to clear all the default
> values.
>
>  Also instead of a zero length string, you should be setting the control to
> Null.
>
> Jim.
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of B
> Heygood
> Sent: Tuesday, February 13, 2018 1:44 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Dirty Cancel Clear all controls
>
> I think me.undo is working. But need to clear entries to get to an
> unsullied
> new record.
>
> See on the web that some variable set and checked in the beforeupdate event
> might help.....
>
> Private Sub cmdCancel_Click()
>
>  On Error GoTo cmdCancel_Click_Error
>
>     If Me.Dirty Then Me.Dirty = False
>     'DoCmd.GoToRecord , , acNewRec
>      Dim ctlC As Control
>         ' For each control.
>        For Each ctlC In Me.Controls
>            If ctlC.ControlType = acTextBox Then
>                 ' Clear New Value.  THIS IS WHERE THE ERROR HAPPENS ON THE
> CONTROL FOR THE PRIMARY KEY ++++
>                ctlC.Value = ""             '        Me.txtEquipID
>            End If
>         Next ctlC
>    Me.Undo
>
>     Me.txtEquipID.SetFocus
>
>
>    On Error GoTo 0
>    Exit Sub
>
> Bob
>
>
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> Rocky Smolin
> Sent: Tuesday, February 13, 2018 10:30 AM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Dirty Cancel Clear all controls
>
> Try Me.Undo
>
> r
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> Bob
> Heygood
> Sent: Tuesday, February 13, 2018 10:03 AM
> To: 'Access Developers discussion and problem solving'
> Subject: [AccessD] Dirty Cancel Clear all controls
>
> Hello to the list,
> I am looking to allow my user to bail and trash all info entered and not
> save the record. And goto a new record.
> Have a button "Cancel".
> I have used the isdirty and the cancel methods of the form.
> Somehow not getting it done.
>
> Maybe the order in which I am attempting ??
>
>
> A 2010 W 8.1
>
> Tia
> Bob
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list