Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERTING RECORDS

Status
Not open for further replies.

NW

Programmer
Feb 3, 2000
61
GB
Does any one know how to insert record (into MS access table) to a specific location using VB code?

 
Is there a way to sepcify where (i.e. before or after current record, before or after record 3) to append a record?

Example:

record1 "Smith","1 Old Road"
record2 "James","23 The croxs"
record3 "Pet", "Hill av"

If the current record position is at record no3
insert befor should =>
add a new record between rec2 & 3
insert after should =>
add a new record after record 3.

I cannot use INSERT INTO as it always add to the bottom of the table.

Hope this is clear.
Thanks for your reply.
 
I won't say it's not possible in a Jet/Access table (though I don't think it is), but you're breaking a cardinal rule of relational database theory, namely, that you should not assume a definite ordering of rows unless you use an ORDER BY clause.

The theoretically pure way to do this is to include a sequencing column by which you order. Actual sequence numbers don't work out too well, because even if you space them out (100, 200, 300 etc.), you can eventually run out of room between numbers. A little more effective is to use a floating point number. If you want to add a row between rows with sequence column values of A and B, just set its sequence column to (A+B)/2.
 
What is the objective of trying to physically order the rows. Is it by last name, timestamp, etc.? You can always return the rows in the order you desire by using an order by on your sql statment. In a realational db the physical order of the rows is not important in most cases.

Rayman
 
I'm trying to create a structure of a database (Access) without using Access database along with some other field attributes not available in Access. RickSpr(MIS) given a possible answer using floating nos.
Is there another easy way of doing this (i.e. creating a random access file first & then copied every thing back?)
How can I create a random access file?
Thanks for your time.
NW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top