LinkCriteria on a report

G

Guest

Im attempting to open a report based on user input. Which report to open is
based on a combo box and that worked fine until I added a start and end date
at which point, no matter what date range I enter, it is returning nothing.
Here is my code, what am I doing wrong?
Dim stLinkCriteria As String
Dim stDocName As String
If [Combo7] = "Recalls" Then stDocName = "RecallReport"
If [Combo7] = "Corporate Projects" Then stDocName = "CorporateReport"
If [Combo7] = "Return to Vendor" Then stDocName = "RTVreport"
stLinkCriteria = "[DateIssueFound] > " & Me![Start] & " and
[DateIssueFound] < " & Me![End]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
 
R

Rick Brandt

Hendricks97 said:
Im attempting to open a report based on user input. Which report to
open is based on a combo box and that worked fine until I added a
start and end date at which point, no matter what date range I enter,
it is returning nothing. Here is my code, what am I doing wrong?
Dim stLinkCriteria As String
Dim stDocName As String
If [Combo7] = "Recalls" Then stDocName = "RecallReport"
If [Combo7] = "Corporate Projects" Then stDocName =
"CorporateReport" If [Combo7] = "Return to Vendor" Then
stDocName = "RTVreport" stLinkCriteria = "[DateIssueFound] > " &
Me![Start] & " and [DateIssueFound] < " & Me![End]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Some coding style suggestions and you weren't delimiting your dates...

Select Case Me!Combo7
Case "Recalls"
stDocName = "RecallReport"

Case "Corporate Projects"
stDocName = "CorporateReport"

Case "Return to Vendor"
stDocName = "RTVreport"
End Select

stLinkCriteria = "[DateIssueFound] > #" & Me![Start] & "# and
[DateIssueFound] < #" & Me![End] & "#"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
 
G

Guest

Thats exactly why debugging doesnt work on 3 hours sleep. Thanks

Rick Brandt said:
Hendricks97 said:
Im attempting to open a report based on user input. Which report to
open is based on a combo box and that worked fine until I added a
start and end date at which point, no matter what date range I enter,
it is returning nothing. Here is my code, what am I doing wrong?
Dim stLinkCriteria As String
Dim stDocName As String
If [Combo7] = "Recalls" Then stDocName = "RecallReport"
If [Combo7] = "Corporate Projects" Then stDocName =
"CorporateReport" If [Combo7] = "Return to Vendor" Then
stDocName = "RTVreport" stLinkCriteria = "[DateIssueFound] > " &
Me![Start] & " and [DateIssueFound] < " & Me![End]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Some coding style suggestions and you weren't delimiting your dates...

Select Case Me!Combo7
Case "Recalls"
stDocName = "RecallReport"

Case "Corporate Projects"
stDocName = "CorporateReport"

Case "Return to Vendor"
stDocName = "RTVreport"
End Select

stLinkCriteria = "[DateIssueFound] > #" & Me![Start] & "# and
[DateIssueFound] < #" & Me![End] & "#"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
 

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