Day of the week

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I want to set the RecordSource for a field on my form txtDayofWeek that
should give me the day of the week of the txtDateEntered field.

txtDateEntered is a Date/Time field, it stores it stores for example today's
date as 1/6/2004, now I want the txtDayofWeek to show *Tuesday* and so on.

Thanks,

Scott
 
Here's a possible way to solve your problem....with no
coding involved.

Create a new table....I called mine 'tbl_Day'. Create 2
fields in your table....Day_Nr(field type integer) and
Day_Text(field type text). Fill in the values that
correspond to each day of the week...for instance, Day_Nr
=1, Day_Text = Monday.

Add a new text box to your form, and add a statement
similar to the following as the control source:

=DLookUp("[Day_Text]","tbl_Day","Weekday(YourDateField)=
[Day_Nr]")

This uses the weekday function to look up the
corresponding value in your tbl_Day table. You could also
do the same thing by writing a Select Case statement in
VBA.
 
Back
Top