Solved

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

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 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