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!

Displaying the Weekday based on a date

Status
Not open for further replies.
Jan 21, 2001
5
0
0
US
I need to display the weekday in a form based on a date entry. The value does not need to be stored, just displayed. A textbox would do fine. I have already made a two field table called "Weekday" with one record for each weekday but I am having problems with the "select" code. Any takers.

Thanks in advance.
 
Enter this as the controlsource of the textbox:

=Format(Date(),"dddd")

or:

=Format([txtSomeOtherDate],"dddd")

where [txtSomeOtherDate] is a textbox on your form containing a date.

 
You can use a bilt in function from Access.

put this code on the Load Event of the form:

Private Sub Form_Load()
DateTxtBox = WeekdayName(Weekday(Date), , vbSunday)

End Sub

Note: Date is the system date, you can use to a date enter form a text box just replace the Date with Cdate(textbox name). Cdate covert String to date.

ALbano
 
Getting the weekday to show after I enter a date in a differant cell has been a challenge for me also,following the first tip shows up the day of the week in the form but the cell in the original table remains blank. I will need the day of the week for reporting purposes in my database. What's up?
thanks!
 
If you want a second textbox to indicate the actual word for the weekday based on the entry in another box try this:

The second textbox gets updated by the entry in the first. Or do the same with a label to avoid user interference and use less memory:
[tt]
Private Sub Date_AfterUpdate()
Text14 = WeekdayName(DatePart("d", [Date]))
End Sub


Private Sub Date_AfterUpdate()
Label14.Caption = WeekdayName(DatePart("d", [Date]))
End Sub

[/tt]


Using the CDate and Cstr functions is the best way to make sure that the correct data typing is done (I'm relying on the program's ability to convert data types intuitively here).

I'm not sure this is the most efficient way of doing it but it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top