By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,149 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,149 IT Pros & Developers. It's quick & easy.

adding a record to a form

P: 250
i would like to add a new record to a form and have it appear after the current record i am on... so for instance if i am on record 2 of 5 i would like to insert a new record that would now be the 3rd record on the form... is this possible?
Jan 27 '10 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,545
Not easily, Didacticone. SQL-based databases have no concept of record position; the order in which records appear is defined by field ordering within the underlying query on which you base your recordset (or on the imposed ordering of any indexes used by the database engine for recording primary keys, if you are basing your form directly on a table). Such ordering is not absolute in any sense - you can change it by changing the SORT BY clause in your query.

To do as you want you would need to include some kind of 'sequence number' field in your table. You would need to set this yourself in event-driven code in some way (you can't just use an autonumber field and get the effect you are after). You would have to look after the modification of 'record positions' of other records so you can set the value of the current field accordingly, then re-query your form after adding a new record to the list in place of the current record in third position.

Personally, I'd not recommend such an approach at all - as if you want to change the sort order of your query then your 'absolute record numbering' goes out the window anyway...

Jan 27 '10 #2

Expert 2.5K+
P: 3,072
You can "move" rows by adding a sequence field and manage the order by code. Check my sample showing how this can be done by opening the "Up down" form.

The other form shows how you can use one table to move selected items between listboxes.

Jan 28 '10 #3

Post your reply

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