Now do you think I would want to reduce your research time after I've spent time doing itThis would help me understand your code and reduce my research time in understanding your code.
This doesn't need changing so if you want to understand what these are just do some research1. Is CurrentProject and Allforms reserved words? Please explain.
2. Is Controls a reserved word? I don't see it on frmRecords.
Yep!3. Case 1 uses option 1 which user fills in sdate and edate blocks. If value is null is it's going to load calendar date 1/1/1900? Is that a pretty good understanding of Case 1?
Yup!4. Case 2 uses option 2 which prompts user with a InputBox for start and end date. If len = 0 then load start and end values with 1/1/1900. Is that correct?
Yap! As long as you name all the controls exactly the same as what I have. You don't have to name your form or report the same but make sure to change the code.5. I should be able to use your "where clause" as is. Is that correct?
No6. If I missed something, can I ask more questions?![]()
Private Sub Command8_Click()
output:
On Error GoTo no_data
Select Case Me.Option3 = On_Focus
Case 1
DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "(((ECP_T.F_ECP_DTE) Between [Forms]![Frm_ECP_CompletedAB]![SDate] And [Forms]![Frm_ECP_CompletedAB]![EDate]))"
Case 2
DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "(((ECP_T.F_ECP_DTE) Between [Enter Start Date:] And [Enter End Date:]))"
Case Else
' DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "notnull"
Dim tempDate As Variant
tempDate = InputBox("Error Not Found:")
End Select
Exit Sub
local_err:
rst.Close
' no reservations found
no_data:
Resume exit_ok
exit_ok:
End Sub
Select Case Me.Option3 = On_Focus
"(((ECP_T.F_ECP_DTE) Between [Forms]![Frm_ECP_CompletedAB]![SDate] And [Forms]![Frm_ECP_CompletedAB]![EDate]))"
The code wasn't based on my concept. kalesb just chopped the SELECT CASE statement from itI've not looked at the example database (not on my Office 2007 machine so accdb is a no-no) but I can see a few things I would flag up in that code.
Private Sub Command8_Click()
Dim tempDate As Variant
tempDate = InputBox("Display InputBox")
output:
On Error GoTo no_data
Select Case Option3
Case 1
DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "(((ECP_T.F_ECP_DTE) Between [Forms]![Frm_ECP_CompletedAB]![SDate] And [Forms]![Frm_ECP_CompletedAB]![EDate]))"
tempDate = InputBox("Error Case 1")
Case 2
DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "(((ECP_T.F_ECP_DTE) Between [Enter Start Date:] And [Enter End Date:]))"
tempDate = InputBox("Error Case 2")
Case Else
' DoCmd.OpenReport "Rpt_CompletedA", acViewPreview, , "notnull"
tempDate = InputBox("Error Case 3")
End Select
Exit Sub
local_err:
rst.Close
' no reservations found
no_data:
Resume exit_ok
exit_ok:
End Sub
[\code]
Code:"(((ECP_T.F_ECP_DTE) Between [Forms]![Frm_ECP_CompletedAB]![SDate] And [Forms]![Frm_ECP_CompletedAB]![EDate]))"
Control references within strings don't work.
The correct way to write that would be: "(((ECP_T.F_ECP_DTE) Between #" & [Forms]![Frm_ECP_CompletedAB]![SDate] & "# And #" & [Forms]![Frm_ECP_CompletedAB]![EDate] & "#"))"
MsgBox Option3
It sure will.Would this work:
Code:msgBox Nz(Option3,"No selection")
Private Sub Command8_Click()
Dim tempDate As Variant
Dim SDate As Variant
Dim EDate As Variant
On Error GoTo X_Err
Select Case Me.optDates
Case 1
DoCmd.OpenReport "Rpt_ECP_CompletedA", acViewPreview, , "ECP_T.F_ECP_DTE Between #" & Form_Frm_ECP_CompletedAB.SDate & "# And #" & Form_Frm_ECP_CompletedAB.EDate & "#", , "For dates between " & Form_Frm_ECP_CompletedAB.SDate & " And " & Form_Frm_ECP_CompletedAB.EDate
Case 2
Start_Sdate:
SDate = InputBox("Enter your starting date (m/d/yy)", "Start Date", DateAdd("d", -90, Date))
If SDate = vbNullString Then Exit Sub
If Not IsDate(SDate) Then GoTo Start_Sdate
Debug.Print SDate
Start_Edate:
EDate = InputBox("Enter your starting date (m/d/yy)", "Start Date", Date)
If EDate = vbNullString Then Exit Sub
If Not IsDate(EDate) Then GoTo Start_Edate
Debug.Print SDate
DoCmd.OpenReport "Rpt_ECP_CompletedA", acViewPreview, , "ECP_T.F_ECP_DTE Between #" & SDate & "# And #" & EDate & "#", , "For dates between " & SDate & " And " & EDate
Case Else
tempDate = MsgBox("Error Case 3")
End Select