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

date parameter

P: n/a
i got date parameter but it shows only 2007 records and not for other
year and would like to know where i have writte code wrong it shows
month only from 1/3/2007 to 2/4/2007 not able to figureout y.
Option Compare Database
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
Private Sub cmdweek_Click()
'sets the Date From and Date To text boxes
'to show complete working week (mon - fri)

Dim today

today = Weekday(Date)

Me!txtDateFrom = DateAdd("d", (today * -1) + 2, Date)
Me!txtDateTo = DateAdd("d", 6 - today, Date)

End Sub
Private Sub cmdyear_Click()
'Sets the Date From and Date To text boxes
'to show complete current year

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

End Sub
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "rptDateParameterReport"

'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

If Len(Me.txtDateFrom & vbNullString) = 0 Or Len(Me.txtDateTo &
vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into
the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub

Apr 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Apr 12, 7:43 pm, bhav...@gmail.com wrote:
i got date parameter but it shows only 2007 records and not for other
year and would like to know where i have writte code wrong it shows
month only from 1/3/2007 to 2/4/2007 not able to figureout y.
Option Compare Database
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

Private Sub cmdweek_Click()
'sets the Date From and Date To text boxes
'to show complete working week (mon - fri)

Dim today

today = Weekday(Date)

Me!txtDateFrom = DateAdd("d", (today * -1) + 2, Date)
Me!txtDateTo = DateAdd("d", 6 - today, Date)

End Sub

Private Sub cmdyear_Click()
'Sets the Date From and Date To text boxes
'to show complete current year

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

End Sub
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "rptDateParameterReport"

'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

If Len(Me.txtDateFrom & vbNullString) = 0 Or Len(Me.txtDateTo &
vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into
the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenReport stDocName, acPreview

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub
I figured out the erroe sorry for wasting your time

Apr 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.