Form is dirtying a new record unintentionally (1 Viewer)

Isaac

Lifelong Learner
Local time
Today, 00:52
Joined
Mar 14, 2017
Messages
4,734
I have a bound form whose recordsource is a Sharepoint list. The only code in the form's load event is:
Code:
blAllowSave_frmDP2_CreateRecord = False 'global variable
Me.txtPRL.SetFocus 'bound textbox

There is code in the form's BeforeUpdate event:
Code:
If blAllowSave_frmDP2_CreateRecord = False Then
    Cancel = True
End If

Even if the only thing I do is open the form and then close it, I get the message "You can't save this record at this time"

If I comment out the form's BeforeUpdate event code, I don't get the pop-up warning, but then of course, a new record gets created.

The form's Data Entry property is set to "Yes" - and indeed, that is the sole intended purpose of the form.

Is this totally normal? I cannot remember. By opening/going to a new record (with absolutely no other action of any kind to dirty it), has Access already begun to create the new record? It seems like this should only happen if and when some other act dirties it - like entering anything in a bound control. Kind of like you see if you open a Table in Datasheet mode...and the ID gets created at the moment you begin typing in a column--otherwise, it's just like a 'pending potential' new record.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:52
Joined
Aug 30, 2003
Messages
35,068
I wouldn't expect that to dirty the record either. Is the variable declared at the form level or in a standard module? I don't think it should dirty the record either way, but I'm going to set up a test and wanted to duplicate the environment.
 

Isaac

Lifelong Learner
Local time
Today, 00:52
Joined
Mar 14, 2017
Messages
4,734
The variable is declared in a standard module, one that only holds global variables.
I was wondering maybe it's just a Sharepoint thing, that it behaves like that.
I solved it by providing a 'close' button that does an Undo, but let me know if you come across anything interesting, or how it behaves for you.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:52
Joined
Aug 30, 2003
Messages
35,068
I'm going to guess it's a Sharepoint thing, but I've never used Sharepoint so I can't test that. I just tested with an Access table and the form performed as we would both expect. The before update event didn't fire unless I actually changed something. Simply opening and closing the form didn't fire it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:52
Joined
Feb 28, 2001
Messages
19,633
Do you have a default value in any of the fields for that record? That will dirty a record really quickly.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:52
Joined
Sep 12, 2006
Messages
14,465
Is it a record entry form? are you creating a new record and setting some non visible, or even a non bound field
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:52
Joined
Aug 30, 2003
Messages
35,068
Do you have a default value in any of the fields for that record? That will dirty a record really quickly.

Not in my experience or testing, at least with an Access BE.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:52
Joined
Feb 19, 2002
Messages
31,689
Is this an AWA or a regular Access form bound to SharePoint?

If it's an Access form, put msgboxes in the Open, Load, Current, BeforeInsert, BeforeUpdate, and Dirty events so you can see at what point Access thinks the form is dirty. The Dirty event fires as soon as someone types a character but I don't know if it fires before or after the BeforeInsert event.
 

Users who are viewing this thread

Top Bottom