You have to state the comparison explicitly for each compare:
ElseIf dtFirstLetter.Value <= #12/5/2006# > #5/31/2008# Then
Should be
ElseIf dtFirstLetter.Value <= #12/5/2006# And dtFirstLetter.Value >=
#5/31/2008# Then
Note: The Value property is not required. It is the default property for a
form control
ElseIf dtFirstLetter <= #12/5/2006# And dtFirstLetter >= #5/31/2008# Then
works the same way. The only time I have use the Value property is when I
am using a With/End With on a control and I need to test the value.
With txtSomeControl
If .Value = "fooo" Then
.Undo
MsgBox "No " & .Value & " Allowed Here"
Cancel = True
End If
End With
--
Dave Hargis, Microsoft Access MVP
"BMaerhofer" wrote:
> Hello,
> I am trying to program a range of dates to determine which version of the
> report that should be pulled. Here is the criteria:
>
> rptINITIALLETTER2 = 6/1/08 and newer based from when First Letter was sent
> rptINITIALLETTER1 = 5/31/08 through 12/5/06
> rptINITIALLETTER = Any others before 12/5/06 or by record number
>
> I have the code listed below. Letter 2 seems to be working properly, it is
> just the other two that keep causing me trouble. I keep changing the order
> of the code for the date range to try to fix it and it causes either letter
> or letter1 to work, but not both together. So I just need to get the range
> set correctly and it should work.
> (<= #12/5/2006# > #5/31/2008#) - Changed this around quite a bit to try to
> get it to work correctly. Please Help!
> ------------------------------------------------------------------------------------------------
>
> If dtFirstLetter.Value > #6/1/2008# Then
> strCriteria = "[Record ID] = " & intID.Value
> Select Case modMatch.intLetter
> Case 1
> DoCmd.OpenReport "rptINITIALLETTER2", acViewPreview,
> "qryInitialLetter", strCriteria
> Case 2
> DoCmd.OpenReport "rptINITIALLETTER2", acViewPreview,
> "qryInitialLetterDEERS", strCriteria
> End Select
>
>
> ElseIf dtFirstLetter.Value <= #12/5/2006# > #5/31/2008# Then
> strCriteria = "[Record ID] = " & intID.Value
> Select Case modMatch.intLetter
> Case 1
> DoCmd.OpenReport "rptINITIALLETTER1", acViewPreview,
> "qryInitialLetter", strCriteria
> Case 2
> DoCmd.OpenReport "rptINITIALLETTER1", acViewPreview,
> "qryInitialLetterDEERS", strCriteria
> End Select
> Else
>
>
> If NLET.Value = False Then
> strCriteria = "[Record ID] = " & intID.Value
> Select Case modMatch.intLetter
> Case 1
> DoCmd.OpenReport "rptINITIALLETTER", acViewPreview,
> "qryInitialLetter", strCriteria
> Case 2
> DoCmd.OpenReport "rptINITIALLETTER", acViewPreview,
> "qryInitialLetterDEERS", strCriteria
> End Select
> Else
>
>
> THANKS!!!!
> --
> BWM
|