469,167 Members | 2,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

adding a record to a form

264 256MB
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
2 1609
Stewart Ross
2,545 Expert Mod 2GB
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...

-Stewart
Jan 27 '10 #2
nico5038
3,080 Expert 2GB
You can "move" rows by adding a sequence field and manage the order by code. Check my sample http://bytes.com/attachments/attachm...tright2000.zip 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.

Nic;o)
Jan 28 '10 #3

Post your reply

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

Similar topics

3 posts views Thread by Jim Heavey | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.