If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Access date in 1 field and day in another
I have a Form that allows me to enter the date in one field and the day of
the week (as a 3 letter day) into another field. I want to have the day computed once it has been entered into the date field, so I don't have to enter the day in the day field. How can this be done and what area does the code get placed? Thanks for any and all help. |
#2
|
|||
|
|||
Access date in 1 field and day in another
George,
You can use the AfterUpdate event of the date control, something like: Private sub txtDate_AfterUpdate if isdate(me.txtDate) then me.txt_DayOfWeek = format(me.txtDate, "ddd") else me.txt_DayOfWeek = NULL end if End Sub If txtDate is a bound control, then you will also need to put this code in the Form_Current event, or call this subroutine from that event. Private Sub Form_Current Call txtDate_AfterUpdate End Sub HTH Dale It t "George" wrote in message ... I have a Form that allows me to enter the date in one field and the day of the week (as a 3 letter day) into another field. I want to have the day computed once it has been entered into the date field, so I don't have to enter the day in the day field. How can this be done and what area does the code get placed? Thanks for any and all help. |
#3
|
|||
|
|||
Access date in 1 field and day in another
Don't bother to STORE the value in a field. You can calculate it whenever you
need it using Format([YourDateField],"ddd") The only reason to actually store the day name would be if you had a very large dataset and needed to search on the day of the week across tens of thousands of records AND the performance was unacceptable. Normally not an issue. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County George wrote: I have a Form that allows me to enter the date in one field and the day of the week (as a 3 letter day) into another field. I want to have the day computed once it has been entered into the date field, so I don't have to enter the day in the day field. How can this be done and what area does the code get placed? Thanks for any and all help. |
#4
|
|||
|
|||
Access date in 1 field and day in another
On Sat, 16 Jan 2010 14:07:01 -0800, George
wrote: I have a Form that allows me to enter the date in one field and the day of the week (as a 3 letter day) into another field. Why? So the user can type #1/18/2010# into the textbox and have "Wed" in the other? I want to have the day computed once it has been entered into the date field, so I don't have to enter the day in the day field. The Control Source property of the second textbox could be =Format([firsttextbox], "ddd") to display the date. The second textbox would not be editable and would not be stored in the table (but of course you wouldn't want either). -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|