473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Weekday function

17
I am having problems with my code. I am trying to look at a date on a form and show me the weekday number for that date on the same form different text box. I am using MS ACCESS 2013 VBA

Expand|Select|Wrap|Line Numbers
  1. Private Sub TxtAppointmentDate_BeforeUpdate(Cancel As Integer)
  2.  
  3. Dim D As Date
  4. Dim W As Integer
  5. D = (TxtAppointmentDate)
  6. W = Weekday(D)
  7. Me.test = W
  8.  
  9. End Sub
Oct 24 '14 #1
5 1388
Stewart Ross
2,545 Expert Mod 2GB
One thing that strikes me is that you are using the BeforeUpdate event of the textbox concerned. If the date is being entered manually you will need to use the AfterUpdate event instead. BeforeUpdate fires before the textbox has a final value in it, allowing you to cancel the update if necessary. Your assignment statement is not going to work correctly as the textbox by definition has not yet been updated to a final state when you try to make the assignment.

AfterUpdate fires after the value has been entered, and this is what you need for your assignment statements to operate correctly(as far as I can tell from the little you have mentioned to us).

Having said all that, there are easier ways you could do this, such as setting the RowSource property of the other textbox to

Expand|Select|Wrap|Line Numbers
  1. =weekday([YourFieldOrControlName])
replacing the fieldname as appropriate to your particular circumstances.

-Stewart
Oct 26 '14 #2
GDC1970
17
Excellent thanks for your feedback, ill follow your suggestions.
Oct 26 '14 #3
twinnyfo
3,653 Expert Mod 2GB
@Stewart,

Minor correction: should set the ControlSource property, not RowSource.

I know what you meant, but wanted to clarify for OP and others.
Oct 27 '14 #4
Stewart Ross
2,545 Expert Mod 2GB
Thanks for the correction twinnyfo - see what happens when I rely on my memory of the property involved. -S
Oct 28 '14 #5
twinnyfo
3,653 Expert Mod 2GB
No problem. Your advice to OP was spot on.
Oct 28 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chumley the Walrus | last post by:
I can't locate a weekday function in asp.net, whereas I just want to grab the weekday associated with a given date. I'm using this date format {0:MM/dd/yyyy} in references in my code, just need to...
3
by: Todd D. Levy | last post by:
I want to be able to determine (from a date entered by the user) what the Day of the Week is for that date. Does MS Access have that function? If it makes any difference, I am using Access...
1
by: jimfortune | last post by:
From: http://groups-beta.google.com/group/comp.databases.ms-access/msg/769e67e3d0f97a90?hl=en& Errata: 19 solar years = 2939.6018 days should be 19 solar years = 6939.6018 days Easter...
18
by: jimfortune | last post by:
I have an A97 module called modWorkdayFunctions in: http://www.oakland.edu/~fortune/WorkdayFunctions.zip It allows the counting of workdays taking into consideration up to 11 U.S. holidays. ...
1
by: Kd | last post by:
I am currently using a form with Weekdays Mon Tues Wed Thur Fri This is generated by a table that the days are being entered manually I would like to create a form that the days updated...
2
by: rob | last post by:
Hello all, I have a report that is always due 14 weekdays (Monday thru Friday) from the day it is suspensed. I would like to use the DateAdd function using the weekday interval (...
4
by: dgmoore | last post by:
I've hit a snag - I know this is easy, but the logic is escaping me. I need to set criteria in a query to find dates in a date field that lie between Tuesday of the current week and Tuesday of the...
9
by: Dave | last post by:
What is the C# Equivalent to VB's Weekday function? I'm trying to convert this: Select Case Weekday(CurrentDate) Case 1 ' Sunday WKG = CurrentDate Case 2 ' Monday WKG = CurrentDate + 6 Case...
1
by: mdaniel1 | last post by:
I finished a button click function that would alert with the time and date, it was working. I saved, closed notepad+, came back later and now when I click nothing, no error codes at the bottom,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.