473,405 Members | 2,354 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,405 software developers and data experts.

report date month error

hi
i have created a form forreport with today, week month & year CMD
Button
but i think i wrote the code wrong for month and also it shows me only
records for this year whewe as i have 2006 records too code is written
in Event Procedure of Respective Cmd Button Can there be a problem in
TODAY'S Cmd Button code that it shows me only 2007 record PLEASE HELP.
Private Sub cmdMonth_Click()
'sets the Date From and Date To text boxes
'to show complete month (from start to end of current month)

Me!txtDateFrom = CDate("01/" & Month(Date) & "/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtDateFrom))

End Sub

Apr 12 '07 #1
3 1611
Tom
I have two functions to determine the first and last of a month given
a date...

***********************
Public Function fncFirstofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
fncFirstofMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)

....
End Function
*******************************************
Public Function fncLastofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
dtmResult = fncFirstofMonth(dtmDate)
dtmResult = DateAdd("d", -1, DateAdd("m", 1, dtmResult))
fncLastofMonth = dtmResult

....
End Function
*******************************************

Add error handling as appropriate.

HTH

Tom

Apr 12 '07 #2
On Apr 12, 5:51 pm, "Tom" <rtmn...@swbell.netwrote:
I have two functions to determine the first and last of a month given
a date...

***********************
Public Function fncFirstofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
fncFirstofMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)

...
End Function
*******************************************
Public Function fncLastofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
dtmResult = fncFirstofMonth(dtmDate)
dtmResult = DateAdd("d", -1, DateAdd("m", 1, dtmResult))
fncLastofMonth = dtmResult

...
End Function
*******************************************

Add error handling as appropriate.

HTH

Tom

Its showing error thou i Expected End Sub
Private Sub cmdMonth_Click()
Public Function fncFirstofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
fncFirstofMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)

End Sub
Public Function fncLastofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
dtmResult = fncFirstofMonth(dtmDate)
dtmResult = DateAdd("d", -1, DateAdd("m", 1, dtmResult))
fncLastofMonth = dtmResult

End Sub

Private Sub cmdtoday_Click()
'sets the Date From and Date To text boxes
'to Today's Date

Me!txtDateFrom = Date
Me!txtDateTo = Date

End Sub
Apr 12 '07 #3
On Apr 12, 7:23 pm, bhav...@gmail.com wrote:
On Apr 12, 5:51 pm, "Tom" <rtmn...@swbell.netwrote:


I have two functions to determine the first and last of a month given
a date...
***********************
Public Function fncFirstofMonth(dtmDate As Date) As Date
Dim dtmResult As Date
fncFirstofMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)
...
End Function
*******************************************
Public Function fncLastofMonth(dtmDate As Date) As Date
Dim dtmResult As Date
dtmResult = fncFirstofMonth(dtmDate)
dtmResult = DateAdd("d", -1, DateAdd("m", 1, dtmResult))
fncLastofMonth = dtmResult
...
End Function
*******************************************
Add error handling as appropriate.
HTH
Tom

Its showing error thou i Expected End Sub

Private Sub cmdMonth_Click()
Public Function fncFirstofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
fncFirstofMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)

End Sub
Public Function fncLastofMonth(dtmDate As Date) As Date

Dim dtmResult As Date
dtmResult = fncFirstofMonth(dtmDate)
dtmResult = DateAdd("d", -1, DateAdd("m", 1, dtmResult))
fncLastofMonth = dtmResult

End Sub

Private Sub cmdtoday_Click()
'sets the Date From and Date To text boxes
'to Today's Date

Me!txtDateFrom = Date
Me!txtDateTo = Date

End Sub- Hide quoted text -

- Show quoted text -
Thanks for the help but i figured out the error

Apr 13 '07 #4

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

Similar topics

1
by: Rajani | last post by:
Hello, I have a table(msaccess) with the structure... job_code text 6 style text 10 qty number fabrication text 65 ship_date date/time
3
by: Norma | last post by:
I am trying to capture data in a date parameter query that spans from 1 to 3 months. I have a field that is a checkbox that notes whether or not this data is 'red flagged' (so you know, the red...
0
by: Rahul Chatterjee | last post by:
Hello All I have designed a dotnet application using VB which basically takes a selection and passes value to a crystal report which in turn passes the value to a Stored procedure. After the...
9
by: rinmanb70 | last post by:
I have a table of transactions, some with past dates, some dated the current date, and some dated in the near future. On a report, I'm looking for a way to get four different sums using the...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October,...
2
by: Bob | last post by:
I've searched this group and have not found any posts since 2001, so I'm hoping that now there may be a better way. I have a need to generate a report that looks like a outlook monthly calendar...
3
by: gmazza via AccessMonster.com | last post by:
Hi there, I am trying to run a report using a parameter for where the user chooses a month from a combo box. Then on the report, I want it to compare the month to a date field and choose only...
3
by: HowHow | last post by:
I need to sort the "DateOfBirth" by the day (dd) regarless of month (mm)and year (yyyy). I have a query called q_DC_Client, in criteria, I am using this code below: Like "*" & "/" & !! & "/" & "*"...
6
by: tmoon3 | last post by:
Hello All, I have a report where it lista employees that need to have an eval done in the next 30 days. If the employee has a 3 month, 6 month or 12 month eval due in the next 30 days it lists...
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
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...
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...
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
agi2029
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,...
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.