Subform: me.dirty not working

Posted on 2004-11-22
Last Modified: 2006-11-17
I've got a form and a subform in Access 2000 (with SQL Server 2000 back-end, so this is an ADP, in case that's important).

In the subform, users can enter a value in a column called EbayNum. Some event code runs so that as SOON as the EbayNum value is entered into the subform control, the rest of the subform row will populate with other data, whether or not the user has clicked off of that subform row.

Generally this works fine, except that I need to have the subform get committed before the user has clicked off of the row. I am using Me.Dirty = False, but I keep getting the following error: "Runtime error '2115': The macro or function set to the BeforeUpdate or Validation Rule property for this field is preventing Microsoft Access from saving the data in the field."

Any clue why I'm getting this error? If I comment out the Me.Dirty statement, I can MANUALLY click the little pencil on the left of the subform row to make it not dirty.... Why can't I make that happen in the event code?
Question by:Galisteo8
    LVL 10

    Accepted Solution

    Instead of just changing the state of dirty, save the actual record.
        If Forms!frmCustomerMain.Dirty Then
            ' Forms!frmCustomerMain.SetFocus ' Use this if the subform doesn't have the focus before saving
            DoCmd.RunCommand acCmdSaveRecord
        End If

    Changing the state of dirty is simply leaving access unsure about what to do with the changes. Forcing a save instead of just changing the dirty state should work.
    LVL 8

    Author Comment

    Awesome, that got it.  Well... that plus moving the event to AfterUpdate instead of Before Update.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now