A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access date in 1 field and day in another



 
 
Thread Tools Display Modes
  #1  
Old January 16th, 2010, 10:07 PM posted to microsoft.public.access.queries
George
external usenet poster
 
Posts: 883
Default 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  
Old January 16th, 2010, 10:23 PM posted to microsoft.public.access.queries
Dale Fye
external usenet poster
 
Posts: 2,651
Default 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  
Old January 17th, 2010, 03:41 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default 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  
Old January 17th, 2010, 09:19 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.