Solved

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

Posted on 2016-09-16
2
41 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 51

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

626 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