Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then OpenReport...I said open report!

Status
Not open for further replies.

Donkeygirl

Technical User
Nov 30, 2000
52
US
lol
Ok I have a form for viewing lists. The user chooses 1 of 2 options from the first option group on the form. It allows them to decide if they want to see a list including data from areas, or for a specific area. If they choose 2 then they also choose an area from a drop down combo box. Then they go to the second option group. This is where they decide what type of list they want. Now every report that shows a type of list for all areas works, but the reports for specific areas don't. None of them open or respond on click. Every report is attached to their own query which asks for the form's area field in the criteria.

can you help me fix this?
My entire upgrade of this db is fixed once this is.
This is the code...

Private Sub cmdSldview_Click()
Dim intWarning As Integer
Dim strReport As String
Dim intTask As Integer: intTask = Me![Task Where?]
Dim intStodone As Integer: intStodone = Me![Stodone]

If intStodone = 1 And IsNull(Me![Sdate1]) Then
intWarning = MsgBox("You must enter the date required", vbCritical, "Incomplete Data")
Exit Sub
End If

If intStodone = 2 And (IsNull(Me![Sdate1]) Or IsNull(Me![Sdate2])) Then
intWarning = MsgBox("You must enter both dates required", vbCritical, "Incomplete Data")
Exit Sub
End If

If intTask = 1 Then
If intStodone = 1 Then strReport = "R-Schedule - By Date"
If intStodone = 2 Then strReport = "R-Schedule - By Date Interval"
If intStodone = 3 Then strReport = "R-Schedule - To Do"
If intStodone = 4 Then strReport = "R-Schedule - Done"
If intStodone = 5 Then strReport = "R-Schedule - All"
ElseIf intTask = 2 Then
If intStodone = 1 Then strReport = "R-Schedule By LD - By Date"
If intStodone = 2 Then strReport = "R-Schedule By LD - By Date Interval"
If intStodone = 3 Then strReport = "R-Schedule By LD - To Do"
If intStodone = 4 Then strReport = "R-Schedule By LD - Done"
If intStodone = 5 Then strReport = "R-Schedule By LD - All"
Exit Sub
End If
DoCmd.OpenReport strReport, acViewPreview
End Sub


why do the first half of the reports work, but not the second?
grrrrr. lol
please excuse any wrapping that may be present in the text of the code.
Thank you all.
Donkeygirl,
Kickin' the crap out of Access
 
Donkeygirl,

You have an "exit sub" right before "End if" which is stopping things before the report is opened.

Also, I noticed you use a lot of "if thens". A cleaner way to code this is shown below.

Code:
Select Case intStodone
    Case 1
        strReport = "R-Schedule - By Date"
    Case 2
        strReport = "R-Schedule - By Date Interval"
    Case 3
        strReport = "R-Schedule - To Do"
    Case 4
        strReport = "R-Schedule - Done"
    Case 5
        strReport = "R-Schedule - All"
End Select
 
I saw this last night, and thought, 'that won't be it. I'll have to wait for more replies.'

well, well, well, I come in this morning and remove the exit sub(<<<evil! evil I tell you!)

yep. I have been working on that for over a month, and yep that was the only problem. Thank you so much!
I now have a really cool database application. And it works!
hehe Donkeygirl,
Kickin' the crap out of Access
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top