Subform: me.dirty not working

Posted on 2004-11-22
Medium Priority
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

slamhound earned 300 total points
ID: 12651651
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.

Author Comment

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


Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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…
Suggested Courses

850 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