473,385 Members | 2,044 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,385 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 1387
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.