473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What is the event that occurs right after a record number is generated?

I'm trying to trigger some code to fire right after a user enters their first character into any field in the record. I can't seem to identify the proper event. I'm having a little difficulty understanding the difference between an "Update" and an actual post to the table. Here's what I think I know, and don't know:

User types first character into any field in record...

BeforeInsert: Occurs before the autonumber field creates a number.
<unknown event>: Occurs immediately after the autonumber field creates a number.

User leaves the record:
BeforeUpdate: Occurs just before the record is updated to the table.
AfterUpdate: Occurs just after the record is updated to the table.

AfterInsert: Occurs after record is inserted into table. (How is this different from AfterUpdate?)

If you can help me identify the <unknown event>, I'd appreciate it.
Thanks,
Adam
Nov 4 '09 #1

✓ answered by Megalog

Sorry I think I misread your post.. I was assuming you were trying to work with the autonumber data itself. The OnDirty event is probably what you are looking for, as OB suggested.

If you're trying to fire off your code for a specific condition, say a new record, then you can always add something like this to your OnDirty event:

Expand|Select|Wrap|Line Numbers
  1. If Me.NewRecord Then
  2.   <your function call>
  3. End If

16 2692
OldBirdman
675 512MB
The OnDirty Event for the form should work.
Nov 4 '09 #2
Megalog
378 Expert 256MB
Adam, can you explain why you're hunting for this event? As far as I know, there isnt an event tied to the autonumber generation.. it's just behind the scenes or parrallel to the OnDirty event. The OnDirty event may not be what you're looking for either, since the autonumber doesnt exist as a value yet when the event first occurs.

Give us a bit more information on what your objective is and we'll be able to help you out more.
Nov 4 '09 #3
Megalog
378 Expert 256MB
Sorry I think I misread your post.. I was assuming you were trying to work with the autonumber data itself. The OnDirty event is probably what you are looking for, as OB suggested.

If you're trying to fire off your code for a specific condition, say a new record, then you can always add something like this to your OnDirty event:

Expand|Select|Wrap|Line Numbers
  1. If Me.NewRecord Then
  2.   <your function call>
  3. End If
Nov 4 '09 #4
ADezii
8,834 Expert 8TB
I'm not sure if this is actually relevant in this case, but if you wanted to fire an Event every time that a Character is entered into a Text Box on a Form, then you can use the Change() Event of the Control. For instance, running the following code within the Change() Event of a Text Box Control named Text15, when the User typed Bytes is for me! will result in:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text15_Change()
  2.   Debug.Print Me![Text15].Text
  3. End Sub
Expand|Select|Wrap|Line Numbers
  1. B
  2. By
  3. Byt
  4. Byte
  5. Bytes
  6. Bytes 
  7. Bytes i
  8. Bytes is
  9. Bytes is 
  10. Bytes is f
  11. Bytes is fo
  12. Bytes is for
  13. Bytes is for 
  14. Bytes is for m
  15. Bytes is for me
  16. Bytes is for me!
Nov 4 '09 #5
Thanks all,

Dirty is OK, but it's not exactly what I was looking for. Dirty will fire whenever a change occurs on the form, so it will fire when anyone enters a new record AND when anyone edits an existing record.

I'm looking for an event that only fires immediately after a new record is created, but not yet updated. I suppose I could use an "if" statement to weed out all the Dirty events that occur during an edit, but I'm surprised a more specific event doesn't address this.

-Adam
Nov 4 '09 #6
MMcCarthy
14,534 Expert Mod 8TB
If the new record generates an autonumber you could fire the event in the AfterUpdate event of that control. This will fire as soon as the record is generated which I think (I'm open to correction :D) is triggered as soon as a new record is created in the table.

Funny I was only discussing this with NeoPa last week and he was more up on this event trigger than me so I might ask him to weigh in here.

Mary
Nov 5 '09 #7
NeoPa
32,556 Expert Mod 16PB
It seems that most of the relevant events have already been covered here. This only leaves me the Form_AfterInsert event to recommend.

Dig through Help for a full explanation including limitations (You cannot abort from the Form_AfterInsert, etc).
Nov 5 '09 #8
NeoPa
32,556 Expert Mod 16PB
Scratch that. I've read through the thread again I realise now you are attempting to put in some code between the creation of the AutoNumber value and the new record itself (and also you mentioned the Form_AfterInsert event in your OP anyway). The bad news (for you) is that there is (quite sensibly - It's not really something I can imagine anyone should have access to) no way to interfere at this point. Access must guarantee certain things about records with AutoNumbers which it would not be in such a position to do if random code were allowed to run between the creation of the value and the record. Form_AfterInsert is still there for grabbing the data as soon as it's created. It simply doesn't do it before the record is created (for the reasons described above).

It would be interesting to hear what you had in mind for this event anyway Adam.
Nov 5 '09 #9
Here's what I was doing:

I'm using my Access database to create text files that I upload to another database - a commercial database that I have no control over. Most people submit their data to this commercial database manually. I need to do this in volume.

Most people track their records on this database by a name or title they give it. I wanted to create a name based on the record number, so later, I could simply download my records from this commercial database, and match it back to the original records I created in Access.

My original idea was this: While enter data into the form, each time I create a new record number, run a custom function that generates a code-name using the record number - so I would be certain I wasn't uploading duplicate names to the commercial database. In essense, each time a new record number is created, run a function that returns a code-name based on the record number, and put it in a field on the form - then continue entering more info into the form.

I know, I know - I'm making a data field that's based on another field - but since I could not make changes to the name once it was uploaded, I figured it would work out.

I know there are other ways to do this - I could have used an AfterUpdate event on any field - but since I couldn't be sure if the user was going to enter all the data (they might not enter the field i set the trigger on), I thought a trigger based on immediate record creation would be best - and I thought this would be simple. When I noticed that the event I was using didn't work, I began looking at the other events and I began to realize that none of the events exactly fit. I consider myself an intermediate Access developer, and I figured I was missing something, so I tossed the question out here.

I've since created a work around, but I still wanted to explore this because I've run into it before. I'm sure there is a way to do this and I just don't know it.

-Adam
Nov 6 '09 #10
missinglinq
3,532 Expert 2GB
@msquared
It's really good to have you back, Mary! Since you're open to correction, I'll do just that! Since the Autonumber field is not populated by physically entering data, the control's AfterUpdate event won't fire. You'd have to explicitly call the AfterUpdate event, and then we'd be right back where we started, looking for an event to fire it in.

@AdamOnAccess
Megalog's code showed you how to have the function fire in the OnDirty event only if you're dealing with a new record.

@Megalog
Linq ;0)>
Nov 7 '09 #11
Me.NewRecord!!!!

I missed it! Bravo!!!

Megalog, thanks for the answer!
Linq, thanks for showing me that I need to read the code more carefully! :)

... and thank you all for the help!

-Adam
Nov 7 '09 #12
MMcCarthy
14,534 Expert Mod 8TB
@missinglinq

Shucks! I just knew I was wrong. Oh well, it had to happen some time :D

Nice to be back.

Mary
Nov 7 '09 #13
missinglinq
3,532 Expert 2GB
I've made mistakes before, too, Mary!

Just ask my three ex-wives!

Linq ;0)>

P.S. It really is good seeing you back with us!

You've been much on my mind of late!
Nov 8 '09 #14
MMcCarthy
14,534 Expert Mod 8TB
@missinglinq
We'll catch up soon :)
Nov 8 '09 #15
NeoPa
32,556 Expert Mod 16PB
@AdamOnAccess
Thanks for the update Adam.

There aren't many explanations for wanting that which would make much sense. I'm happy to say that it seems yours does ;) It's easy to assume because something is rare that the OP is just getting confused, but I'm pleased to see that's not so (and particularly that I wasn't suckered into the assumption).

I'm glad Linq picked up on the idea you possibly hadn't caught MegaLog's post. I wondered a little at the time, but it didn't occur to me to check with you until I saw this explanation and had a better idea of where you were coming from.
Nov 8 '09 #16
NeoPa
32,556 Expert Mod 16PB
@missinglinq
Sorry I couldn't let you know it was coming Linq. The Dragon Queen has been on the verge a few times recently and when I've said to expect her soon she hasn't appeared. I'm just very glad she is now :)
Nov 8 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andrés Guerrero | last post by:
Hi, I'm working with Ms Access 97 and I have two tables like these: Table: Person Table: Phone Field: ID (Autonumeric) (primary key) Field: Person_ID (foering key)...
2
by: Ron | last post by:
Hi all Just wondered if there's a list somewhere that explains when the events on forms, reports, etc fire. I'm looking for the order of things. Like, the first event to fire when a new form...
3
by: DavidGeorge | last post by:
I have 2 subforms, neither of which is linked to the main form. Of the left of my form is a subform with a list of organisations and on the right is a subform with details of the organisation...
1
by: matthewemiclea | last post by:
I have a subform, where in the "on current" event, I display code that is supposed to recognize which record I am pointing to, and then display more specific info in another subform based on that...
15
by: Susan Bricker | last post by:
Greetings. I have a Mainform with a subform. The Mainform has single record format and subform has continuous form format. When the Mainform opens, I force allowadditions and allowedits to FALSE...
26
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using...
9
by: Jay | last post by:
Everywhere I go (read/browse) I see these parameters.... ByVal sender As Object, ByVal e As System.EventArgs Yet I never see them used within the function/method. Could someone tell me what they...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: dana1 | last post by:
I have a form with several combo boxes in the header used to determine the records that will be displayed on the form. When I tab or enter from the last combo box in the header, I want the focus to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.