With the following code when I a new record is added it is added at the top of the table, how can I get the record added after all the existing records?
Please Login or Register to view this content.
With the following code when I a new record is added it is added at the top of the table, how can I get the record added after all the existing records?
Please Login or Register to view this content.
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assisted or failed to assist you I welcome your Feedback.
This isn't the answer, however it may give you some ideas.
If you look at the Northwind Db example(guessing you are using 2007). The purchase order module and recordsetwrapper class will show you some examples.
I hope this helps some.
Your code doesn't necessarily add it to the top of the table. It probably appears that way based on how the table is sorted. You can either change the saved sort that is on the table (if you have an autonumber, sort ASC on that) or add an order by clause in any subesequent querying you do on the table.
split_atom18
I actually have 2003 & the IT department will not give me access to the example databases
Thanks for your reply
bhill
The table is not sorted and the new entry always appears as the 1st entry
I know that I can sort when using queries but as I use a form that is directly linked to the table to view the records - so sorting a query is not an option
I need the newest entry to always be the last record in the table,
At present the newest entry is 1st , it then runs oldest to the 2nd last newest
If you hit the F5 key to refresh the form does it move to the bottom?
If so add
"Call Refresh" to your code.
I am trying to recreate what is happening to you so I can test some things. However, not doing a very good job at recreating it.
Hope this helps,
Dan
Hi mudraker,
Not wanting to be pedantic about this, but wouldn't your situation be an ideal reason to "have" a query between your table and form? Is there a reason why you MUST link your form directly to your table?I know that I can sort when using queries but as I use a form that is directly linked to the table to view the records - so sorting a query is not an option.
Cheers,
Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.
split_atom18
Even when I open & look at the table manually the newest entry is always the 1st entry in the table.
ConneXionLost
I am self taught & I am still at the early days of learning - & may not have learnt the best way to do this.
I extract data from a master table to a secondry table - this is done via 1 of 30 sql vba sql statements.
By having the data in a secondry table I can change entries without affecting the main database - this gives me the option of saving or discarding the changes I have made
In you control source field on your form put the following, with you fields.
SELECT [tbExtractedMeterDB].ID, [tbExtractedMeterDB].[Customer ID] FROM [tbExtractedMeterDB] ORDER BY [tbExtractedMeterDB].ID;
Basic break down.
Select (List fields here using a "," to seperate each field in the table you want to display) From [table name] ORDER BY Fields to Asc
So if you have 5 fields you want to display in your table. Giving your fields numbers 1-5. And you want to order them by field 3.
SELECT [tbExtractedMeterDB].[1], [tbExtractedMeterDB].[2], [tbExtractedMeterDB].[3], [tbExtractedMeterDB].[4], [tbExtractedMeterDB].[5] FROM [tbExtractedMeterDB] ORDER BY [tbExtractedMeterDB].[3]
Hope this helps,
Dan
mudraker
The position of a record in an Access table should have no bearing.
If you are relying on the position then I think you are going to face problems.
Still having problems?
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!
I have not had much time to look at it
Still having problems at the moment
I may need to build a query that pulls all data from the table and then set the from to use the query
split_atom18
Looks like you pointed me in the right direction
I have placed the following in the record source field
and tthe following in the Order By fieldPlease Login or Register to view this content.
The above appears to give me what I wantPlease Login or Register to view this content.
As form & datadbase is still being built, I have not fully tested it.
Thanks for your assistance
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks