Solved

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

Posted on 2016-09-16
2
39 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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