Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2003
    Location
    Newport, RI
    Posts
    6

    Unanswered: Can you force a form to be dirty?

    I want to force a form to be dirty when the user creates a new record. When the form is dirty, I highlight a Save button and force the user to save (or cancel) the changes before moving on.

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Can you try setting the value of a field to the same value?

    ie..
    me!SomeFieldName = me!SomeFieldName
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Disregard...I didn't read the part about a new record. Can you set some field to a value (a good field to use would be to have a DateEntered field and setting it to date().
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    This will make it dirty! Note that that's " " not ""

    Code:
    Private Sub Form_Current()
    If Me.NewRecord Then
      Me.AnyTextBox = " "
    End If
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Just out of interest...
    Can you simply set Me.Dirty = True in VBA?
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Yes and no! You can, but not simply! You have to set focus to a control first then assign Yes to Dirty.

    Code:
    Private Sub Form_Current()
     If Me.NewRecord Then
      Me.AnyTextBox.SetFocus
      Me.Dirty = True
     End If
    End Sub
    It's one more line of code, but maybe a little less cryptic, which I like!

    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Nov 2002
    Posts
    272
    Quote Originally Posted by rogerb1221
    I want to force a form to be dirty when the user creates a new record.
    I would not do this. If a record is new and the user didn't enter any data, I don't want to confuse him with an enabled Save button.

  8. #8
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Forms do have an On Dirty event. Maybe this could be used ??
    Code:
    Private Sub Form_Dirty(Cancel As Integer)
        cmdSave.Enabled = True
        cmdCancel.Enabled = True
    End Sub
    However, I generally use the Before Update event to ask the user if he/she wants to save or cancel the (changed) data, if the form is dirty.

    If I have save/cancel buttons, then they don't do anything if the form is not dirty.

    MTB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •