If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Print Report Using Cascading Combo Boxes on Form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 01-31-12, 11:13
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
WOW! THANK YOU PAUL!!
The Print Reports Form is now working perfectly!! YAY!! THANK YOU ` THANK YOU!!!

One more quick question....on the one combo box where I to Select Year, how do I get it to select a particular year, or ALL years? I currently have an SQL statement in my row source for that combo box, but it isn't working.

SELECT [Project Year] FROM [Grant] UNION Select "(All)" ,
From [Grant]
ORDER BY [Project Year];
Reply With Quote
  #17 (permalink)  
Old 01-31-12, 11:50
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Excellent!

In the code behind your button, test that combo. If it's "All", don't use the wherecondition argument.
__________________
Paul
Reply With Quote
  #18 (permalink)  
Old 01-31-12, 13:23
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
Paul-
I'm just not seeing it....checked the code behind my button which is as follows:

Private Sub PrintPreviw_Click()
If Not IsNull(SelectReport) And SelectReport <> "" Then
DoCmd.OpenReport SelectReport, acViewPreview, , "[Project Year] = '" & Me.SelectYear & "'"
Else
MsgBox ("You Must First Select a Report To Print!")
SelectReport.SetFocus
End If
SelectReport = ""
End Sub


And the SQL for the combo box on the control source is as follows:

SELECT DISTINCT [Project Year] FROM [Grant] UNION Select "(All)" From [Grant]
ORDER BY [Project Year];


I'm so close to having this done....now its the little thing that is a hinderance. What am I missing?
Reply With Quote
  #19 (permalink)  
Old 01-31-12, 13:30
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
You're not seeing it because you haven't built it yet.

Where the DoCmd line is now you'd have an If/Then/Else block that tested the year combo. If it contains "(All)" then open the report with no wherecondition, else open it with the wherecondition you have now. Not having a wherecondition is how you'd get all years.
__________________
Paul
Reply With Quote
  #20 (permalink)  
Old 01-31-12, 16:03
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
OK....HELP.....I have no clue how to use the If/Then/Else statement with the DoCmd line. I've searched all day looking for samples. I understand what you are saying, just have no clue how to code it. I am truly a beginner at Access coding.
Reply With Quote
  #21 (permalink)  
Old 01-31-12, 16:47
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Code:
If Me.ComboName = "(All)" Then
  DoCmd...
Else
  DoCmd...
End If
__________________
Paul
Reply With Quote
  #22 (permalink)  
Old 02-01-12, 14:37
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
How do I incorporate another If/Then/Else Statement when I already have one? This is what I currently have:

Private Sub PrintPreviw_Click()
If Not IsNull(SelectReport) And SelectReport <> "" Then
DoCmd.OpenReport SelectReport, acViewPreview, , "[Project Year] = '" & Me.SelectYear & "'"
Else
MsgBox ("You Must First Select a Report To Print!")
SelectReport.SetFocus
End If
SelectReport = ""
End Sub

I really hate having to keep asking you about this Print Reports Form....but if I can get this section to function, it will be completed. I will just have to make everything "pretty"...LOL
Reply With Quote
  #23 (permalink)  
Old 02-01-12, 14:56
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Like I said, replace the existing DoCmd line with the If/Then block I showed you:

Code:
  If Not IsNull(SelectReport) And SelectReport <> "" Then
    If Me.ComboName = "(All)" Then
      DoCmd...
    Else
      DoCmd...
    End If
  Else
    MsgBox ("You Must First Select a Report To Print!")
    SelectReport.SetFocus
  End If
__________________
Paul
Reply With Quote
  #24 (permalink)  
Old 02-02-12, 07:53
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
PERFECT! THANK YOU PAUL!
All of my coding is working just like I needed it to....all thanks to you! Thanks for bearing with me! You're the best!

Now I will be cleaning up the forms and reports - which is easy.

THANKS AGAIN!!!!
Reply With Quote
  #25 (permalink)  
Old 02-02-12, 09:41
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
Hate to be a bother, but I am trying to get a text box (ReportLabel) in my Report Header to reflect the year selected in the combo box(SelectYear) on the Print Reports Form. What is wrong with this code?

Private Sub Report_Open(Cancel As Integer)
With Reports![GMFinancial]
.ReportLabel = "Project Year: " & Forms!PrintReports.SelectYear
End With

Me.GroupLevel(0).ControlSource = Forms!PrintReports.SelectSort
'Set the sort by asc or desc
If Forms!PrintReports!SortOrder = "Ascending" Then
Me.GroupLevel(0).SortOrder = False
Else
Me.GroupLevel(0).SortOrder = True
End If
End Sub



Since that wasn't working....I tried putting
=[Forms]![Print Reports]![Me].[Select Year]
as the control source for the text box on my report.

Thats not working either. This seems so simple....

Last edited by renickj; 02-02-12 at 09:56.
Reply With Quote
  #26 (permalink)  
Old 02-02-12, 10:48
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
__________________
Paul
Reply With Quote
  #27 (permalink)  
Old 02-02-12, 14:15
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
And the DB is now complete! THANK YOU PAUL!!!!
Reply With Quote
  #28 (permalink)  
Old 02-02-12, 14:55
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Yay!! Happy to help!
__________________
Paul
Reply With Quote
  #29 (permalink)  
Old 02-16-12, 14:32
renickj renickj is offline
Registered User
 
Join Date: Jan 2012
Posts: 23
Another Delima - Grouping Report

Hi Paul!
I have run into another delima with my DB and was hoping you could assist me, again.

I'm attaching the DB so you can walk through it and see what I am referring to.

Open "Print Reports" Form. Select "GMFinancial" Report. Select "2011-2012" Year. Select "Project Number" Sort. And then select "Ascending" Sort Order. Click Print Preview.

This report comes up perfectly (). BUT, I need to split into 3 different groups. I've done this via SubReports, but it makes all the subreports show up in the Select Reports Combo Box on the Print Reports Form (which will completely confuse users of the DB). I'm thinking there is a way to do this with the Sort/Group option in the detail section of the report, via expression.

I need the groups to print on one report as follows:
Group 1 - All records not in group 2 or 3.
Group 2 - All records which have "yes" in the "RollFromPreviousYear" field AND have "O" in the "Status" field.
Group 3 - All records which have "yes" in the "NoCostExtension" field AND have "O" in the "Status" field.

Each of the 3 groups would have a subtotal and then the report footer would have a Grand Total. (Keep in mind that when I say "all records" it would only be the records for the year selected on the Print Reports Form.

I've tried creating (and deleted) a query for each group and then used that SQL as the expression in the group option on the report, but I get a syntax error.

Is what I am wanting possible? If so, could you please help me in getting the coded correctly? If it works, I will be applying the code to one of the other reports also.
Thanks in advance for any assistance!!!
Jeannie
Attached Files
File Type: zip Grant_Mngmnt.zip (489.5 KB, 3 views)
Reply With Quote
  #30 (permalink)  
Old 02-21-12, 14:33
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Sorry, I didn't see this earlier. Did you get it sorted out? Offhand I'd have a field in the query along the lines of:

GroupOnMe: IIf(RollFromPreviousYear="Yes" And Status = "0", 2, IIf(NoCostExtension="Yes" And Status = "0", 3, 1))
__________________
Paul
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On