Inserting Record VBA

paulkc

Board Regular
Joined
May 18, 2007
Messages
220
Office Version
  1. 365
I have a form with a subform that shows a subset of information from my table based on the date on the master form. The details showing in the subform have a field that gives a sort order for that particular date. What I would like to do is be able to select a particular record and insert a record either above or below that record. I feel certain that what needs to happen is for the code to change the order field on all the following fields to the next number and then the new record would have the vacated order. Then the code would refresh the form giving the effect of the inserted field. I just don't know where to start on this. Thanks for any help you may be able to give.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Databases don't insert rows in any particular order (and not "above or below rows" either) - it's not something you want to be constantly managing. The best I can think if you really need to do this is to use a Double in the sort value field. If you want a row after 5 then give it the value 5.5. Or if if after 5.5 then 5.55, and so on. Or increment in 100's and leave plenty of room "in between". Better would be to use a natural sort key - order number, name, date, ID, and so on.
 
Last edited:
Upvote 0
I actually like that suggestion. I do need them in a specific order because it deals with a sequence of events. Thanks for the input.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top