473,386 Members | 1,908 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,386 software developers and data experts.

Form Help---Weekday

Kd
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 themselves by 7
days each time a new record is opened.
Any and all thought are appreciated
Kd

Nov 13 '05 #1
1 2011
Kd wrote:
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 themselves by 7
days each time a new record is opened.
Any and all thought are appreciated
Kd


There is a weekday function. By Default, Sunday is 1, Saturday is 7.
You need to supply a date to it tho. Let's say we enter in debug window
? Weekday(Date())
Since today is Oct 18th, 2005...a Tuesday, the number is 3. So if we enter
? date() + 8-weekday(Date())
we alway go to the next Sunday

From here, we can display either a 3 char day name or the full day name
? format(Date(),"ddd")
Tue
? format(Date(),"dddd")
Tuesday

Now you want to create a record with the days. It might be better to
fill in the field with the date instead of day name because you can
always format it to display the day but...
Dim rst As DAO.Recordset
Dim intFor As Integer
Dim datStart As Date
datStart = date() + 8-weekday(Date())

set rst = Currentdb.Openrecordset("TableToAdd7DaysName",dbop endynaset)

For intFor = 0 to 6
rst.AddNew
'add the date and later use format
rst!DateFieldName = datStart + intFor

'or add the 3 day format
rst!DayNameString = Format(datStart + intFor,"ddd")

'or add the full day format
rst!DayNameString = Format(datStart + intFor,"dddd")

rst.update
Next
rst.close
set rst = Nothing

You can cut this code out and paste in a module and run it as an example
of how it works.

Sub junk()
Dim intFor As Integer
Dim datStart As Date
datStart = Date + 8 - WeekDay(Date)
For intFor = 0 To 6
'add the date and later use format
MsgBox datStart + intFor & vbNewLine & _
Format(datStart + intFor, "ddd") & vbNewLine & _
Format(datStart + intFor, "dddd")

Next
End Sub
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
4
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the...
19
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.