473,396 Members | 1,832 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.

Instantly update a table based on inputs to a continuous form

60
Hi Everyone,

I have been going crazy trying to figure this out and I'm sure it's easy. I have a continuous form based on a table. Once someone enters a new record on the form I have code in the "before insert'" property of the form that reads the max record id from the table and adds 1 to it and enters it on the form. (I'm using this in place of an auto number field to record a unique id). I cannot use an auto number field here so it must be done this way. Unfortunately the record is not added to my table until after the person is finished filling out all the fields. The problem is that before they finish filling out the data, another user could try to add a record and will end up with the same max record Id because the other person's record hasn't been added to the table yet.

Is there any way to immediately add the record to the table the second someone starts adding a record on the form?

Thanks for any and all help.

Ramprat
Nov 19 '08 #1
2 2285
missinglinq
3,532 Expert 2GB
Your problem is in your choice of events for this code. The BeforeInsert event occurs when the user types the first character in a new record, even before the Form_Dirty event fires, so as you've found out, a number of people could be working on new records, all of which have been assigned the same auto-incremented number. The trick is to assign this number at the ***last possible moment*** rather than the ***first possible moment.*** Move your code to the Form_BeforeUpdate event (make it the last line, if you have other code in this event) and you should be fine. The chance of two records being saved at the precise same moment is almost non-existent. Most people, when posting this kind of code, warn about the possibility, but in years of using this type of hack I've never seen it happen, nor have I seen posts from anyone who has.

BTW, an auto-incrementing number like this is the way to go, rather than using an AutoNumber. AutoNumbers should not be seen or heard! They should simply remain in the background for Access to use for housekeeping.

Linq ;0)>
Nov 20 '08 #2
ramprat
60
Thank you Linq!! That was just what I needed. Thanks again.

Ramprat
Nov 20 '08 #3

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

Similar topics

2
by: aaj | last post by:
Hi all I have a continuous bound form and on each record is a tick box. The user ticks the boxes and these boxes define the batch. for future operations before they leave the page I count...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
4
by: Ruben | last post by:
Hi, I have a continuous form that provides a listing of various instruments that are serviced on a monthly to annual basis, with general info about the instrument, last and next service dates,...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
3
by: Robert McEuen | last post by:
Using A2K3, Windows XP I'm handling a many-to-many relationship with a linking table structure as follows (irrelevant fields omitted): tblIssue PK_IssueID (autonumber, primary key) IssueName...
16
by: mlcampeau | last post by:
I'm fairly new to this so I'll try to be as clear as possible. I have a database that stores employee information and all job titles available. I have a main form that is based from a query and...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
17
geolemon
by: geolemon | last post by:
This should be an easy one for anyone with basic forms experience (I'd hate for you guys to be bored!) :D I have a simple form, bound to a single table. I'd *like* the form to work this way:...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.