pass date from calendar to query on a report form

C

cesemj

Hello,
I built a date dialog box form interface to allow the customer to
select a date that is currently selected in the calendar control for
the start date and end date and the values are then passed to a query
field (install_date O when_discovered_date) using the strWhere that is
associated with a option group report.

To do this:
I use the following code below and my result was nada. When I click on
the preview or print button no reports are called, When I try to select
a date the callendar will only let me select the month and year and
nothing eles. the date fields only change in the design mode.
Finally, the option group does not allow me to respond to a selection.
The code compiles but does not do what I would like it to do. Any
information will be helpful.

To view a picture of the page goto: http://members.cox.net/cesemj/

Thank you in advance, for your assistance with this matter.

Chris
(e-mail address removed)
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox

Public Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub
procedures.
' Preview or print report selected in the ChooseReport option
group.
' Then close the Anslq25aReports Dialog form.

Dim strWhere As String
Dim StrStartDate As String
Dim strEndDate As String

StrStartDate = "#" & Format(Me.cboStartDate.Value, "mm/dd/yyyy") & "#"
strEndDate = "#" & Format(Me.cboEndDate.Value, "mm/dd/yyyy") & "#"

strWhere = "issue_date is between " & StrStartDate & " and " &
strEndDate

Select Case Me!ChooseReport
Case 1
DoCmd.OpenReport "LRUMeanTimeBetweenFailures", PrintMode, ,
strWhere
Case 2
DoCmd.OpenReport "MeanTimeToCorrect", PrintMode, , strWhere
Case 3
DoCmd.OpenReport "MeanLogisticsDelayTime", PrintMode, ,
strWhere
Case 4
If IsNull(Forms![frmAnslq25aReports]!SelectCategory) Then
DoCmd.OpenReport "MeanTimeToRepair", PrintMode
Else
DoCmd.OpenReport "MeanTimeToRepair", PrintMode, ,
strWhere
End If
End Select
DoCmd.Close acForm, "frmAnslq25aReports"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub

Private Sub cboEndDate_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)

' Note which combo box called the calendar
Set cboOriginator = cboEndDate
' Unhide the calendar and give it the focus
'ocxCalendar3.Visible = True
ocxCalendar3.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar3.Value = cboOriginator.Value
Else
ocxCalendar3.Value = Date
End If
End Sub

Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)

' Note which combo box called the calendar
Set cboOriginator = cboStartDate
' Unhide the calendar and give it the focus
'ocxCalendar2.Visible = True
ocxCalendar2.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar2.Value = cboOriginator.Value
Else
ocxCalendar2.Value = Date
End If
End Sub

Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub



Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub
 
J

Jeff Boyce

?install_date Between X And Y
(rather than install_date is Between ...)

Regards

Jeff Boyce
<Office/Access MVP>

Hello,
I built a date dialog box form interface to allow the customer to
select a date that is currently selected in the calendar control for
the start date and end date and the values are then passed to a query
field (install_date O when_discovered_date) using the strWhere that is
associated with a option group report.

To do this:
I use the following code below and my result was nada. When I click on
the preview or print button no reports are called, When I try to select
a date the callendar will only let me select the month and year and
nothing eles. the date fields only change in the design mode.
Finally, the option group does not allow me to respond to a selection.
The code compiles but does not do what I would like it to do. Any
information will be helpful.

To view a picture of the page goto: http://members.cox.net/cesemj/

Thank you in advance, for your assistance with this matter.

Chris
(e-mail address removed)
Option Compare Database
Option Explicit
Dim cboOriginator As ComboBox

Public Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub
procedures.
' Preview or print report selected in the ChooseReport option
group.
' Then close the Anslq25aReports Dialog form.

Dim strWhere As String
Dim StrStartDate As String
Dim strEndDate As String

StrStartDate = "#" & Format(Me.cboStartDate.Value, "mm/dd/yyyy") & "#"
strEndDate = "#" & Format(Me.cboEndDate.Value, "mm/dd/yyyy") & "#"

strWhere = "issue_date is between " & StrStartDate & " and " &
strEndDate

Select Case Me!ChooseReport
Case 1
DoCmd.OpenReport "LRUMeanTimeBetweenFailures", PrintMode, ,
strWhere
Case 2
DoCmd.OpenReport "MeanTimeToCorrect", PrintMode, , strWhere
Case 3
DoCmd.OpenReport "MeanLogisticsDelayTime", PrintMode, ,
strWhere
Case 4
If IsNull(Forms![frmAnslq25aReports]!SelectCategory) Then
DoCmd.OpenReport "MeanTimeToRepair", PrintMode
Else
DoCmd.OpenReport "MeanTimeToRepair", PrintMode, ,
strWhere
End If
End Select
DoCmd.Close acForm, "frmAnslq25aReports"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub

Private Sub cboEndDate_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)

' Note which combo box called the calendar
Set cboOriginator = cboEndDate
' Unhide the calendar and give it the focus
'ocxCalendar3.Visible = True
ocxCalendar3.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar3.Value = cboOriginator.Value
Else
ocxCalendar3.Value = Date
End If
End Sub

Private Sub cboStartDate_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)

' Note which combo box called the calendar
Set cboOriginator = cboStartDate
' Unhide the calendar and give it the focus
'ocxCalendar2.Visible = True
ocxCalendar2.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar2.Value = cboOriginator.Value
Else
ocxCalendar2.Value = Date
End If
End Sub

Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub



Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top