Insert vs Append

New Contributor

In VBA, how do you differentiate between a record that is inserted by the user vs. appended in a form?  I have some cached fields in a record that I would like to clear when a record is appended.

4 Replies
no difference. inserted record is not really "inserted" on the location you want it to appear, rather it is Appended at the end of the table.

@TheShah 

You'll have to add some sort of additional information to each record to identify the source. Perhaps a required field that users complete one way or the other.

 

But there's a more interesting question not addressed here.

 

How is it possible that a user inserts a record into a table without doing so through a form? Are your users actually opening tables directly in datasheet view to add new records? If not, what does the difference entail?

And, as Arnel suggested, in practical terms, "Insert" and "Append" are the same thing, so perhaps that's part of the clarification needed to get a good suggestion for you.

 

 

First of all, my choice of word "Insert" was not a good one. In Form, when you ADD a new record, Form's BeforeInsert event is fired and hence I had used the word "Insert" in my question.

I have user only adding a new record via a form. This can be done by either user explicitly providing values or appending a record by copy/paste. I have some fields that if user provided a value explicitly then it was OK but if the same value came because of Copy/Append action it was not OK.

What I just found out is that the Form's dirty event is never fired in the Copy/Append even if you modify some of the controls after the append before save. The form's dirty property is set to true right after the BeforeInsert event and before each control's BeforeUpdate and AfterUpdate events.

The none append case will fire the Form's dirty event right after BeforeInsert event of the form and before each control's BeforeUpdate and AfterUpdate event. I can use this to figure out what I need.

May be there is a better and simpler way. But this is what I figured out so far.

Thx for your responses.

@TheShah

I see, the user can copy/paste values into the fields in the form. I assume, then, it's a form in datasheet view?

This may be more of a training issue than a processing issue, in that case.

 

I know of no practical way to determine how a new value or set of values was entered into the controls on a form.