PC Review


Reply
Thread Tools Rate Thread

Date Range for Report

 
 
BMaerhofer
Guest
Posts: n/a
 
      26th Aug 2008
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
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      26th Aug 2008
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

 
Reply With Quote
 
BMaerhofer
Guest
Posts: n/a
 
      27th Aug 2008
Thanks! The code fixed my issue.
--
BWM


"Klatuu" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date range for a report Tracey Microsoft Access Queries 3 31st Dec 2009 03:31 PM
Date range on report and e-mail report =?Utf-8?B?UGxlYXNlIGhlbHAgSmFtZXM=?= Microsoft Access Reports 2 21st Feb 2007 03:56 AM
Date Range on a report that has multiple date dependent sub report =?Utf-8?B?cnlhbm5leQ==?= Microsoft Access 1 14th Nov 2006 06:28 PM
Date range report =?Utf-8?B?TGl0dGxlIHBldGU=?= Microsoft Access Reports 1 24th Sep 2004 04:11 PM
Report in date range to show each day in range patricia Microsoft Access Reports 1 13th Mar 2004 08:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 PM.