Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms - Day of Week 1

Status
Not open for further replies.

OBarry

Programmer
Nov 14, 2000
16
US
On a form using Access 97 is there a way to create an unbound field to show the day of the week based on the date entered in the date field on the same form?

The function DatePart() does not work to show the days of the week and using the Long Date format (with the Control Panel's Regional Settings Property set to this format) has the day of week and date together in one field and I need the day of week in a separate field.

Can this be done?

Thanks for any help or advice in advance.

 

Hi OB,

Try using WEEKDAY(serial_number,return_type)where serial number is date part or text date 12-01-2000 and return_type will be digit for day of week Sun = 1, Mon = 2, etc.

Jim


 
call a procedure like this (where DOW is the text box for day of week)

Private Sub UpdateDOW()

Dim intDOW As Integer

intDOW = WeekDay(txtDate)

Select Case strDOW
Case 1
DOW = "Sun"
Case 2
DOW = "Mon"
Case 3
DOW = "Tue"
Case 4
DOW = "Wed"
Case 5
DOW = "Thu"
Case 6
DOW = "Fri"
Case 7
DOW = "Sat"
End Select
End Sub


Dave
 
Oops, should be

Private Sub UpdateDOW()
Dim intDOW As Integer

intDOW = WeekDay(txtDate)
Select Case intDOW
Case 1
DOW = "Sun"
Case 2
DOW = "Mon"
Case 3
DOW = "Tue"
Case 4
DOW = "Wed"
Case 5
DOW = "Thu"
Case 6
DOW = "Fri"
Case 7
DOW = "Sat"
End Select
End Sub

===========================

in this example, txtDate is text box where date is located and DOW is text box showing day of week.

Dave
 
I believe using the DatePart function gives the same result as the Weekday function.

intDOW = DatePart("w", txtDate)


Dave
 
Thanks for these suggestions but I couldn't get either one to work, I'm sure that they will work but I just didn't know how to make them work.

Just FYI in case someone else has the need to do this...

This is what I ended up using. Use two fields [DOW] and [Date], in the [Date] field put in an After Update Event Procedure as [DOW].Value = Format([Date].Value, "dddd"). After you type a date in the [Date] field, the day of the week is put in the [DOW] field.

Other Examples:
"dddddd" = Friday, December 8, 2000
"ddddd" = 12/8/00
"dddd" = Friday
"ddd" = Fri

Thanks again for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top