Results 1 to 3 of 3
  1. #1
    dgaletar is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Location
    Washington, DC
    Posts
    85

    Exclamation Need Help Putting Dates in Order...

    Hello. This is how my form currently displays:

    Click image for larger version. 

Name:	dateOrder.png 
Views:	13 
Size:	54.1 KB 
ID:	15330



    As you can see, the dates are all messed up. I need them to show NEWEST to OLDEST.

    The list of dates is pulled in from the following code:

    Code:
    Private Sub Date_Click()
    
    DoCmd.OpenForm "Service Details", acNormal
    Forms![Service Details]![CustomerID].Value = Forms![Vehicles]![CustomerID].Value
    Forms![Service Details]![Service_Date].Value = Forms![Vehicles]![Service subform]!Date
    Forms![Service Details]![Service Work Item Xref subform].Requery
    
    End Sub
    I am sure that this is a fairly simple fix, but I don't know it. If anyone can help, I would surely appreciate it!!!

    Thanks,

    DG

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It looks like the subform that is displaying the date and mileage is in datasheet view, and I am guessing the datasheet record source is based on a table. The form record source should be a query. Record sources that are queries can be ordered (sorted) whereas a table cannot.

    So change the record source to a query and set the sort order to the date descending.

    I never use datasheet view; if I needed that look, I use continuous forms view and create my own datasheet look. IMO, datasheet view is very limiting.


    BTW, "Date" is a reserved word in Access and shouldn't be used for object names.
    Here is a list of reserved word: http://allenbrowne.com/AppIssueBadWord.html

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by ssanfu View Post

    ...Record sources that are queries can be ordered (sorted) whereas a table cannot...
    Actually you can do this with a Table as the Record Source:

    Make sure that the Form's Order By On Load Property is set to Yes

    Set the Order By Property to: [YourDateFieldName] DESC

    Just like that, with Square Brackets around the YourDateField Name, followed by DESC.

    Having said that, it is considered preferable, by many experienced developers, including myself, to base all Forms on Queries, even when only a single Table is involved. And doing this sorting in a Query is how I'd do it.

    Also pay particular attention to ssanfu's advice about not using the Reserved Word Date as a Field name!

    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help Putting Together a Project
    By dazed in forum Access
    Replies: 11
    Last Post: 12-08-2013, 11:12 AM
  2. Replies: 1
    Last Post: 12-19-2012, 10:46 PM
  3. How to order columns in ascending order?
    By darkingthereturn in forum Access
    Replies: 5
    Last Post: 06-18-2012, 05:24 AM
  4. Replies: 3
    Last Post: 04-11-2012, 01:13 PM
  5. Putting an Expression in a Field Box
    By MWB in forum Queries
    Replies: 4
    Last Post: 11-02-2010, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums