I have the start and end dates on my report forms set at the first and last days of the current month.
I also have three buttons for these dates:
One that advances forward one month at a time
One that goes back one month at a time
One that returns to the current month (same code as I use in "OnLoad") - Private Sub CommandBack_Click()
-
Me.DateStart = DateSerial(Year(Me.DateStart), Month(Me.DateStart) - 1, 1)
-
Me.DateEnd = DateAdd("m", 1, (DateAdd("d", -1, DateStart)))
-
End Sub
- Private Sub CommandCurrent_Click()
-
Me.DateStart = DatePart("m", Now()) & "/01/" & DatePart("yyyy", Now())
-
Me.DateEnd = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
-
End Sub
- Private Sub CommandForward_Click()
-
Me.DateStart = DateSerial(Year(Me.DateStart), Month(Me.DateStart) + 1, 1)
-
Me.DateEnd = DateSerial(Year(DateStart), Month(DateStart) + 1, 1) - 1
-
End Sub
- Private Sub Form_Load()
-
Me.DateStart = DatePart("m", Now()) & "/01/" & DatePart("yyyy", Now())
-
Me.DateEnd = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
-
End Sub
4 2019
JEBritt,
Welcome to Bytes!
Is this a question or an attempt at an informative article?
NeoPa 32,556
Expert Mod 16PB
Indeed. It's not clear where you're going with this thread.
By all means, avoid string handling of date and time.
Thus, your code can be reduced to: - Private Sub CommandBack_Click()
-
Me.DateStart = DateSerial(Year(Me.DateStart), Month(Me.DateStart) - 1, 1)
-
Me.DateEnd = DateSerial(Year(Me.DateStart), Month(Me.DateStart), 0)
-
End Sub
-
-
Private Sub CommandCurrent_Click()
-
Me.DateStart = DateSerial(Year(Date), Month(Date), 1)
-
Me.DateEnd = DateSerial(Year(Date), Month(Date) + 1, 0)
-
End Sub
-
-
Private Sub CommandForward_Click()
-
Me.DateStart = DateSerial(Year(Me.DateStart), Month(Me.DateStart) + 1, 1)
-
Me.DateEnd = DateSerial(Year(DateStart), Month(DateStart) + 2, 0)
-
End Sub
-
-
Private Sub Form_Load()
-
Me.DateStart = DateSerial(Year(Date), Month(Date), 1)
-
Me.DateEnd = DateSerial(Year(Date), Month(Date) + 1, 0)
-
End Sub
just information I thought some might find useful.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Psybar Phreak |
last post by:
hi all,
im developing a site in perl with mason on a postgreSQL backend.
i currently have a page that lists all items in a table, but would like to
do the
" << PREVIOUS 1 2 3 4 NEXT>> "...
|
by: eeh |
last post by:
Hi,
Suppose I have a table "product" with fields id,name,price. I want to
get a resultset of previous and current and next record when the
resultset is sorted by id and id=10. The table data is...
|
by: suveetha |
last post by:
I would like to know in javascript how to wirte a code from moving one page to another ie. in my html page i have two frames , the first frame consist of previous and next button , in the second...
|
by: anejamanish |
last post by:
Hi guys
I am developing a website using php and ajax. Here I need to to design previous and next buttons to load new html files with every click.
I am displaying these files within a div tag....
|
by: imrosie |
last post by:
Hello,
I have a app that allows for searching of images by stored (links) name.
The absolute path to the images is what's stored. Not the image.
Located at the bottom of the form is a previous...
|
by: md9108 |
last post by:
I have a previous page and next page coded. The next page works. The previous page gives me an http: 404 error and I can't figure it out. The error is on the line "<td align=left>
<!--
...
|
by: simon2x1 |
last post by:
i have 3 pages,home.php, next.php page and other.php.in the home.php page
i selected name from the database and i gave it a limit and also
an if statement to echo next.for the next.php page and...
|
by: akrao |
last post by:
i want a simple java script code for previous and next buttons. my scenario is i want to display one panel at a display time . fisrt default first panel displays remaining are not visible
and then...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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: 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,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |