By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,564 Members | 810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,564 IT Pros & Developers. It's quick & easy.

report date month error

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.