Piperlynne,
Tw 0things... number one... Please make sure you include the AUthor's name
when available when copying code into your module or pasting it here in the
newsgroup. It's just the polite thing to do...
Second item... Your going to need to apply the strWhere to your report, see
below...
You're going to need something like...
'Author: Allen Browne (
[email protected]), June 2006.
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to
Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Reports![YourReportName].Filter = strWhere
Reports![YourReportName].FilterOn = True
End If
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Ok, sorry for the confusion, I have 2 command buttons off the same filter
boxes. I am able to run the reports and select the format and destination
now
with this code. However, now I'm not applying the filter to the reports.
Where should I put the strWhere clause in the docmd. Line? Or should I
change
my tactic? (So close, yet so far)
The XLS version is:
Private Sub cmdRptALL_Click()
Dim strWhere As String
Dim strReport As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
strReport = "Export ALL"
If Not IsNull(Me.txtSiteFilter) Then
strWhere = strWhere & "([RptSite] Like ""*" & Me.txtSiteFilter & "*"") AND
"
End If
If Not IsNull(Me.txtAEFilter) Then
strWhere = strWhere & "([AccountExec])Like ""*" & Me.txtAEFilter & "*"")
AND "
End If
If Not IsNull(Me.txtStatusFilter) Then
strWhere = strWhere & "([Status] Like ""*" & Me.txtStatusFilter & "*"")
AND "
End If
If Not IsNull(Me.txtThemeFilter) Then
strWhere = strWhere & "([RptTheme] Like ""*" & Me.txtThemeFilter & "*"")
AND "
End If
If Not IsNull(Me.txtSpnsrTypeFilter) Then
strWhere = strWhere & "([SponsorshipType]Like ""*" &
Me.txtSpnsrTypeFilter & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria selected ALL records will be included",
vbInformation, "Nothing to Do"
Else
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
DoCmd.OutputTo acSendReport, "Export ALL", acFormatXLS, , , , ,
acExportQualityPrint
End Sub
and the PDF version is:
Private Sub cmdAERpt_Click()
Dim strWhere As String
Dim strReport As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
strReport = "Account Exec Report"
If Not IsNull(Me.txtSiteFilter) Then
strWhere = strWhere & "([Site] Like ""*" & Me.txtSiteFilter & "*"") AND "
End If
If Not IsNull(Me.txtAEFilter) Then
strWhere = strWhere & "([AccountExec])Like ""*" & Me.txtAEFilter & "*"")
AND "
End If
If Not IsNull(Me.txtStatusFilter) Then
strWhere = strWhere & "([Status] Like ""*" & Me.txtStatusFilter & "*"")
AND "
End If
If Not IsNull(Me.txtThemeFilter) Then
strWhere = strWhere & "([RptTheme] Like ""*" & Me.txtThemeFilter & "*"")
AND "
End If
If Not IsNull(Me.txtSpnsrTypeFilter) Then
strWhere = strWhere & "([SponsorshipType]Like ""*" &
Me.txtSpnsrTypeFilter & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria selected ALL records will be included",
vbInformation, "Nothing to Do"
Else
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
DoCmd.OutputTo acOutputReport, "Account Exec Report", , , , , ,
acExportQualityPrint
End Sub
Gina Whipp said:
Piperlynne,
I.m not sure I understand... so let me say it back to you....
You want to remove...
C:\Documents and Settings\barbabik\My Documents\Export ALL.xls"
....and have the End-User select where to place the file?
I could be missing it but where is the line or section of code for the
.PDF
report?
You're most welcome, glad part one worked!
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Ok, so this works THANK YOU!
However, now I'm trying to take out the set destination to have the user
prompted for where to save the report. What do I need to change. (I also
have
another report that is a PDF (Access 2007) and want to do the same thing
and
am getting an error that they can't find the report. I checked the
spelling
and its correct, but its not working) (2 questions in one there - sorry)
Code:
Private Sub cmdRptALL_Click()
Dim strWhere As String
Dim strReport As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
strReport = "Export ALL"
If Not IsNull(Me.txtSiteFilter) Then
strWhere = strWhere & "([Site] Like ""*" & Me.txtSiteFilter & "*"") AND
"
End If
If Not IsNull(Me.txtAEFilter) Then
strWhere = strWhere & "([AccountExec])Like ""*" & Me.txtAEFilter &
"*"")
AND "
End If
If Not IsNull(Me.txtStatusFilter) Then
strWhere = strWhere & "([Status] Like ""*" & Me.txtStatusFilter &
"*"")
AND "
End If
If Not IsNull(Me.txtThemeFilter) Then
strWhere = strWhere & "([Theme] Like ""*" & Me.txtThemeFilter & "*"")
AND "
End If
If Not IsNull(Me.txtSpnsrTypeFilter) Then
strWhere = strWhere & "([SponsorshipType]Like ""*" &
Me.txtSpnsrTypeFilter & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to Do"
Else
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
DoCmd.OutputTo acSendReport, "Export ALL", acFormatXLS, "C:\Documents and
Settings\barbabik\My Documents\Export ALL.xls"
End Sub
Gina Whipp said:
Piperlynne,
Have a look at...
http://allenbrowne.com/ser-62.html
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
I am trying to create a form that will allow the user to filter the
contents
of a report by up to 6 fields. (Theme, Sponsor, Site, AcctExec,
Advertiser,
Type).
I was leaning on the direction of having Filter On checkboxes that if
checked would point to the fields that the user wanted to filter by.
Then
have comboboxes with the values for the filter. If no check boxes
checked,
no
filter etc.
I have a query that pulls all information and I have done something
similar
in the past (minus the checkboxes) but my brain isn't working.
Basically the question is. . what is the best way to approach filtering
on
0
to many fields.? I'm not extremely vba proficient (I know the very
basics).
Need a little design help please. Basically I'm looking for the
straightest
and simplest line between point a and point b. Ideas?
.
.
.