Determine if this is a New document (1 Viewer)

GaleT

Registered User.
Local time
Today, 14:25
Joined
Oct 18, 2019
Messages
72
I have a VBA import routine that extracts data from specific cells in an excel Worksheet. This routine must only be run on a New document. I also have a macro button to create new documents. How can I determine if a new document has been selected on the form?


Gale
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:25
Joined
Oct 29, 2018
Messages
21,358
Hi Gale. What designates a document as "new?"
 

vba_php

Forum Troll
Local time
Today, 16:25
Joined
Oct 6, 2019
Messages
2,884
gale, check this out:

https://docs.microsoft.com/en-us/of...user-interface-help/datelastmodified-property

you might get what you want by capturing the "DateLastAccessed", "DateLastModified" or "DateCreated" property of the file. I doubt there is any vba code to give you information on whether the data is brand new or not, unless you have another way to verify it.
 

GaleT

Registered User.
Local time
Today, 14:25
Joined
Oct 18, 2019
Messages
72
Hi theDBguy,


I don't exactly know. I used one of the canned button selections to add a new record. It appears to just clear the form...


I was thinking there might be a document property but maybe I just need to clear the form and that will constitute a new document?


Gale
 

GaleT

Registered User.
Local time
Today, 14:25
Joined
Oct 18, 2019
Messages
72
Thank you VBA PHP. That is interesting and similar to what I think I need but I need it at the current Access document level. That may not be necessary though. I am starting to thing there is no such property and I just need to have a blank form to know I am creating a new document.


Gale
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:25
Joined
Oct 29, 2018
Messages
21,358
Hi theDBguy,

I don't exactly know. I used one of the canned button selections to add a new record. It appears to just clear the form...

I was thinking there might be a document property but maybe I just need to clear the form and that will constitute a new document?

Gale
To make sure we're on the same page, what are you referring to with "document?" Are we talking about a record or a file?
 

GaleT

Registered User.
Local time
Today, 14:25
Joined
Oct 18, 2019
Messages
72
Sorry, in this context I am referring to records. I work a lot in Lotus Notes and they are called documents there...



Records :)



Gale
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:25
Joined
Oct 29, 2018
Messages
21,358
Sorry, in this context I am referring to records. I work a lot in Lotus Notes and they are called documents there...

Records :)

Gale
Hi Gale. If you're using code to process a record in like the Current Event of a form and want to exclude "new" records, then you could use the NewRecord property of the form. For example, the following will not execute the code if the current record is a new record.
Code:
If Me.NewRecord Then
    'skip this one because it's a new record
Else
    'do stuff to this record
End If
Hope that helps...
 

GaleT

Registered User.
Local time
Today, 14:25
Joined
Oct 18, 2019
Messages
72
Thank you theDBguy, that is exactly what I was looking for. It didn't occur to me to look for a form property.



Gale
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:25
Joined
Oct 29, 2018
Messages
21,358
Thank you theDBguy, that is exactly what I was looking for. It didn't occur to me to look for a form property.

Gale
Hi Gale. You're welcome. Glad we could assist. Good luck with your project.
 

Users who are viewing this thread

Top Bottom