Go To

rs197290

New member
Local time
Today, 08:21
Joined
Jun 8, 2007
Messages
5
Here's my situation.

I have a table that is sorted by Date and then Time. Let's say that I add a record at 7:00am that has a time stamp as 3:00pm. At 8:00am I have to add another record that has a time stamp of 7:30am. In my table the records show up in the correct order by time stamp (7:30am and then 3:00pm). However, when I open my form that is connected to this table, the last entry with a time stamp of 7:30 shows up as the last record. I need the 3:00pm record to show up last on the form just as it is in the table. Your help is greatly apprieciated.
 
Is your form's "Recordsource" the table, or a query. It needs to be a query with the sort order set on the field of your choice. If you created the form by clicking on the table and using the wizard, it will have set the table as the recordsource.

You can change that by going into the form's properties and clicking the elipsis (...) next to Recordsource and it will ask you if you want to base it on a query and you say yes. Then, you can select the asterisk to select all fields and then you can double click on the field you want to sort by, and then set the sort order in the sort property of the field in the query and uncheck the "display" box for that field (otherwise it will show twice in the query and the second time as EXPR1.

I hope that helps.
 
I think that you might need an entry in the Order by in the Form properties.

Brian
 
I think that you might need an entry in the Order by in the Form properties.

Brian
I agree this is the most robust way of sorting.

If you are only sorting on one field then by far the easiest way to do this is:
- open the form (in normal view)
- click on the field you want to sort
- click on one of the sort icons

Next time you open the form it will sort the same way.

If you need to sort on more than one field then add the field names to the OrderBy property of the form (in edit view).

Chris
 
Thanks Bob, this worked great for one exception. When I open the form it goes to the last record that I need it to. However, when I go back a couple of records and hit my Refresh button which I have set up as a Macro for GoTo Record "Last", it does not go to the record that I need. I tried to point my GoTo Record to go to the last record in the query but I receive the following error, "The object 'Queryname' isn't open". Could you also help out on this one. Thanks again.
 
After setting the form's recordsource to a query did you use this code on the button:

DoCmd.RunCommand acCmdRecordsGoToLast
 
No, I'm not sure where that code would go. Could you explain a little more in detail. If I should do this, could you explain how I would do it and if I dont need to do this could you explain how to take it off?
 
You would put that code in the button's click event. I am attaching some pics to show you where you need to enter the code. IMPORTANT NOTE: This is an example I did for someone else for a different event, but the concept is the same. So, instead of ON CURRENT (as shown in the example) you would use CLICK.

events01.png



events02.png


events03.png
 

Users who are viewing this thread

Back
Top Bottom