Displaying dates

Access Virgin

Registered User.
Local time
Today, 16:48
Joined
Apr 8, 2003
Messages
77
I want to enter the date, eg todays date, 06/02/04 into a text box and when I move from the box I want 2 other text boxes to be filled with

1. The month name and year, ie February 04
2. The day name, ie Friday

I have been trying to use the DatePart function but by using this I can only get the month and day to return as numbers, ie month = 2 and day = 6.

Anybody got any suggestions?
 
For the MonthName & Year:

=Format([MyTextbox], "mmmm yy")


For the weekday:

=Format([MyTextbox], "dddd")




where MyTextbox is the name of your textbox with the date.
 
After a lot of searching, I finally found a ray of hope here...

The first post is exactly what I would like to do, but where do I enter the:

=format([mytextbox],"dddd") formula???


relatively new to access if you couldn't tell and I am sure the answer will be very easy once I see it. Thanks in advance!!
 
Last edited:
OK, put it into the Control Source area and it works, but now the result (i.e.: Thu) is not being put into the table since the Day field is no longer the control source.

Any help on how to get the day to not only show on the form in the text box, but to also stay in the table as a part of the record?
 
Last edited:
Just store the date, you don't need to store the day as well.
The Day can be displayed at any time from a valid date
 
Rich,

Thanks for the reply.

I actually do want to capture the day as it is one of the fields we export to excel for a spreadsheet.

Is this even possible? I have been searching for a while and I am starting to think it is not.
 
You don't need to store the Day as well.
Just add a new field to a query, MyDay: Format([YourDateField],"dddd") export the query
 
sdzc said:
I actually do want to capture the day as it is one of the fields we export to excel for a spreadsheet.

When using Access you should avoid making use of your tables and, at all convenient times, manage your data via queries.

Tables are used for storing data. Queries, on the other hand, allow you to select only the relevant fields, to sort your data, to format the way your data looks, and to restrict the data selected - getting the query right can help improve your database's efficiency.

In this instance you are wanting to store a calculated value in a table. Storing calculated values (without an exceptional reason) is frowned upon in database design as you are creating a non-key dependency where one table relies on one or more fields within the same table but is not dependent upon the table's primary key. An example of a non-key dependency is an orders table with three field called Quantity, Price, Total. Total, of course, is Quantity multiplied by Price. Were the value changed in either the Quantity or Price fields then an additional process would be required to update the Total field otherwise the order Total would add up incorrectly. In this case we turn to a query and ask it to perform our calculation. This ensures that the outcome is always exact.

With your situation you have a date field. From a date we can extract all the individual elements (Year, Month, Day, Hour, Minute, Second) as well as using the ability to format the dates any way we want.

So, in a query we would create a calculated field that references the date field and formats it however we want.

The query can then be exported in lieu of the table with any calculations/formats you wish to add.
 

Users who are viewing this thread

Back
Top Bottom