UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Has New Record Been Created?, Any Version    
 
   
TimTDP
post May 28 2020, 06:44 AM
Post#1



Posts: 1,117
Joined: 16-June 05



A new record can be created when data is manually entered into any field
How can I determine when a new record has been created?
Go to the top of the page
 
Jeff B.
post May 28 2020, 07:26 AM
Post#2


UtterAccess VIP
Posts: 10,489
Joined: 30-April 10
From: Pacific NorthWet


I'm assuming this is happening in an Access form, bound to an underlying query or table. Access forms 'save' a record if the form is "dirty" (i.e., data entered in a bound control) and you exit/close the form, or if you have a <Save> command button you've added … and I'm guessing, depending on where the data is being stored (e.g., Access back-end, SQL-Server back-end, …), you could get a 'blank' new record if <Saved> even without data being entered.

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
missinglinq
post May 28 2020, 07:53 AM
Post#3



Posts: 4,702
Joined: 11-November 02



Exactly when/where are you trying to determine this?

If you need to determine if a Record is a new Record...in order to do something...you can use something like this:

CODE
If Me.NewRecord Then
  'Do something here
End If


Linq ;0)>
This post has been edited by missinglinq: May 28 2020, 07:54 AM

--------------------
BTW...The Monkey is laughing at me...not at any other poster!

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

All posts/responses based on Access 2003/2007
Go to the top of the page
 
projecttoday
post May 28 2020, 08:30 AM
Post#4


UtterAccess VIP
Posts: 12,387
Joined: 10-February 04
From: South Charleston, WV


QUOTE
How can I determine when a new record has been created?

Put a date and time field in the record and populate it with the Now function when the record is first created. Unless you mean you want to be notified when somebody else creates a new record which would require a trigger of some sort.

--------------------
Robert Crouser
Go to the top of the page
 
TimTDP
post May 28 2020, 09:02 AM
Post#5



Posts: 1,117
Joined: 16-June 05



QUOTE
Exactly when/where are you trying to determine this?


I have a subform in a form. I don't want to see the subform until a record has been created in the main form.
So if I enter data in any field on the main form, I take it that a record has been created and then show the subform

Thanks
Go to the top of the page
 
tina t
post May 28 2020, 02:15 PM
Post#6



Posts: 6,685
Joined: 11-November 10
From: SoCal, USA


QUOTE
I have a subform in a form. I don't want to see the subform until a record has been created in the main form.
So if I enter data in any field on the main form, I take it that a record has been created and then show the subform

hmm, well, you might add code to the mainform's BeforeInsert event procedure, as

Me!MySubformControlName.Visible = True

remember that entering data in the mainform will then make the subform visible, but if you hit Esc a couple times you can wipe out the mainform record without saving it - but the subform will still be visible.

also, you would want code in the mainform's Current event procedure to show/hide the subform as you move to/from an existing record to a new blank record. if the primary key value in the mainform's underlying table is Autonumber, you could check for the existence of a primary key value, as

Me!MySubformControlName.Visible = (Not IsNull(Me!MyPrimaryKeyFieldName))

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
projecttoday
post May 28 2020, 03:54 PM
Post#7


UtterAccess VIP
Posts: 12,387
Joined: 10-February 04
From: South Charleston, WV


It's an unusual requirement. It seems like this subform really isn't not visible for very long. Why? There's not condition involved.
You might consider putting a save button on the main form.

--------------------
Robert Crouser
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    9th July 2020 - 06:29 AM