Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2007, 09:49 AM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sorting dates- HELP

Currently on one of my forms I have users choose the date from an ActiveX Calendar Control 11 and store it with the other data they input. My problem is when I try to sort the data by its date, they do not appear in the correct order. If someone enters data on 7/9/2007 and then enters another set of data on 7/25/2007 when I sort it by date the 7/25 entry appears first. From what I can tell Access is seeing 7/2./.... and thinking that it comes before 7/9/.... Is there a way to change the Calendar to save 7/9/2007 as 07/09/2007? Or what would you recommend?
Thanks a bunch for your help
-Rich

 
Old July 25th, 2007, 11:02 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I never use the calendar control, so not sure if there is a way to take the data and format it properly as it is being stored. Well, I know you can do that, but it seems like a kludge.

Are you sure that you are not using a text field to store the data in? That is more likely the cause than the control. The date field should be should be Date/Time, and not Text. (or even number?)

Check that first and let me know.


mmcdonal
 
Old July 26th, 2007, 04:42 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I have found is that the formatting of the date really drives the sorting on the form. I have figured out my own way of having it be reliable, but still look normal to the user.

Here is what I do in this case:

I format the data of the underlying query like this:
Format$([ProductionDate],"yyyy/mm/dd") AS PdateSortsGood

So, the info comes out like 2007/07/25.
But, since the users of the form don't want to see this strange format which make it line up down the form correctly, I reformat in the text box the way the user wants to see it.

Then, in the control source area of your text box properties put it:
=Format$([PdateSortsGood],"mm/dd/yyyy") which will then make it appear common to the user.




 
Old July 26th, 2007, 04:47 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is an example of where is used it in my where clause with the use of calendar dates

Format$(DateAdd("d", 1, Forms![Pop_ProPrinting]!CalendarEnd), "yyyy/mm/dd")

I always do my underneath formatting with yyyy/mm/dd, yet show the user what is common (ie, mm/dd/yyyy, or "ShortDate"

Coby






Similar Threads
Thread Thread Starter Forum Replies Last Post
dates again dhoward VB.NET 2002/2003 Basics 12 August 22nd, 2007 09:48 AM
dates DARSIN General .NET 4 January 14th, 2005 09:09 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
between dates capitala Access VBA 1 May 30th, 2004 05:20 PM
Dates treadmill SQL Language 3 July 3rd, 2003 02:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.