Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Courses > Access > Developer > D13 > < D12 | D14 >
Back to Access Developer 13    Comments List
Developer 13 Date Search Upload Images   Link   Email  
Allan McConnell       
2 years ago
Once again I have run into a Date Format issue. USA to Australian format. Filter form between two dates.

Following along with the course I entered the VB code exactly like the lesson and found it did not work accurately. No matter how I tried to format it, it would not filter properly.

I changed my Regional settings to the US format and the code works perfectly. (As per the code below) It does not work in DD/MM/YYYY or the YYYY/MM/DD Regional format either way, or under my Australian Regional settings.

I can not get my head around the fact that the codes can be affected by the Regional settings as much as it is. I am wondering what it is that I need to change to make this code match that of the Australian Regional settings?

In this lesson this code was built to be used more than one call for code hence the Private Sub "DoSearch ()"

Private Sub DoSearch()

    Me.RecordSource = "SELECT * FROM CustomerT WHERE " & _
        "CustomerSince >= #" & BeginDate & "# AND " & _
        "CustomerSince <= #" & EndDate & "#"
            

End Sub

This then highlights an major problem if designing a data base to work in two different countries that uses two different Regional formats. As mentioned the agreed YYYY/MM/DD format does not work in this case.

Please could someone give me the VB code, for learning  purposes, that I would need to use if programing this to accommodate our regional settings?

If I had to work around this, I would simply do this via a Query and not use the code at all. But while I know what to do in a query, I am here to learn VB.
Kevin Robertson             
2 years ago
Format the dates to the US format.

Me.RecordSource = "SELECT * FROM CustomerT WHERE " & _
   "CustomerSince >= #" & Format(BeginDate, "mm/dd/yyyy") & "# AND " & _
   "CustomerSince <= #" & Format(EndDate, "mm/dd/yyyy") & "#"
Allan McConnell OP       
2 years ago
Thank you Kevin.  Very much appreciated.
Certainly works when set to the US format.
So this something that I will need to program into my mind for future coding.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 13.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/6/2024 7:43:27 PM. PLT: 1s