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 February 9th, 2004, 07:17 AM
Authorized User
 
Join Date: Dec 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 97 Date format problem

Morning All,
‘I have an application where I need to show courses attended for a member for the member’s current training year. So if a member has a training year of 1st November 2003 to 31st October 2004, the app has to show the courses attended during that year.

‘Each member has a record showing the month and day his training year starts

‘I have assigned variables TrMth and TrDay for those integers.

‘To obtain the start date for the member’s training year, I use the following (courtesy Greg Serrano) by ‘initialising the variable dtmStartdate:

dtmStartDate = DateSerial(Year(Date), TrMth, TrDay)

‘then to obtain the end date, I use;

dtmEndDate = DateAdd("yyyy", 1, dtmStartDate - 1)

'I then use a routine to re initialise if appropriate, namely where the date the search is carried out is after ‘31st December in any one year

If dtmStartDate > Date Then
dtmStartDate = DateSerial(Year(Date) - 1, TrMth, TrDay)

dtmEndDate = DateAdd("yyyy", 1, dtmStartDate - 1)
End If

‘This is to ensure that the search always shows the correct year – otherwise a search in early 2004 would show a member’s course starting ist November 2004.

‘The variables are then incorporated into a query to find all the courses between dtmStartdate and dtmEnddate, and the routine works well, save for one problem, which is that dtmStartDate is wrongly formatted. If I run the routine for a member who has not attended any courses for his training year (1st November 2003 to 31st October 2004) the query shows he has attended courses, but is bringing them in from earlier dates. When I examine the query image the following appears in the Course date field:

‘ Between #11/01/2003# And #31/10/2004#
‘instead of
‘Between #01/11/2003# And #31/10/2004#

‘Curiously, the end date is formatted correctly.

‘I imagine this is a formatting problem – any ideas?




 
Old February 21st, 2004, 08:23 AM
Authorized User
 
Join Date: Dec 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem appears to be related to the Regional & Language options in Control Panel. Initially I set the short date option to dd/MM/yyyy (in fact I think the default is that format). Customising the setting to dd/MMM/yyy has fixed the problem. Is this a bug in Windows?

 
Old February 21st, 2004, 12:47 PM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

http://www.mvps.org/access/datetime/date0005.htm





Similar Threads
Thread Thread Starter Forum Replies Last Post
Vb6 access 97 recordset problem Probie VB Databases Basics 3 August 1st, 2007 06:12 PM
ASP/Access Date Format seananderson Classic ASP Databases 2 November 6th, 2006 02:15 PM
Problem with memo field in Access 97 Ardeshir Access 4 December 27th, 2004 06:05 AM
MS Access and ASP : DATE Format failure Sebastiaan Classic ASP Basics 2 October 1st, 2003 12:32 PM





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