Solved

Short dates with starting days 1-12 not being seen 13-31 OK

Posted on 2016-09-16
2
30 Views
Last Modified: 2016-09-16
Hi Experts,

Please find attached Access Form Db.

Please use the FormLookup form and you will notice the Record Name is not being found for certain dates. This would seem to be because the DLookup function is not able to know what is the day and month portion of the date (American and English notation being different) for days 1-12. The DateAdd function does not seem to have this problem and is able to add a day to the correct date.

What is the problem?
DateTest.mdb
0
Comment
Question by:DColin
2 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41801139
Set the Format property of your textbox to "Short Date" and you can reduce your code to:
Private Sub Form_Load()

    Me!txtDate.Value = Date

End Sub

Private Sub btnAddDay_Click()

    Me!txtDate.Value = DateAdd("d", 1, Me!txtDate.Value)
    UpdateRecordName Me!txtDate.Value

End Sub

Private Sub btnMinusDay_Click()

    Me!txtDate.Value = DateAdd("d", -1, Me!txtDate.Value)
    UpdateRecordName Me!txtDate.Value

End Sub

Private Sub UpdateRecordName(lookUpDate As Date)

    Me!txtRecordName.Value = DLookup("RecordName", "Table1", "RecordDate = #" & Format(lookUpDate, "yyyy\/mm\/dd") & "#")

End Sub

Open in new window

/gustav
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 41801145
Really though, if you want to go with the table route, your table should have 2 fields.  The first field should contain the numbers 1 thru 31, and the second field should be the spelled out number.  Then you would just do a dlookup of the day portion of your date using the Day() function.

Ron
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now