View Single Post
  #2  
Old July 7th, 2008, 04:05 PM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 744
Default Excel and filter

On Jul 7, 8:11*am, Ticotion
wrote:
Hi

I have a problem regarding transfering data from a query to excel. The
problem is that I need it to be filtered before transfering so it is only the
requested data that are being transferred.

At the moment the users have a form where they can choose to open an report
or a data report. But they should also have the possibility to open a query
based on the selected inputs.

I use the following code:

Private Sub commandobutten20_Click()

* * If Me.Afkrydsningsfelt25 = -1 Then

* * * * DoCmd.OpenReport "Rpt_AfdelingOEEgraf", acPreview, , "[Yearnb] =" &
Me.Kombinationsboks7 & " And [weeknb] = " & Me.Kombinationsboks5 & " And
[Yearnb] = " & Me.Kombinationsboks9 & " And [Weeknb] = " &
Me.Kombinationsboks11 & " And [Dpt] = """ & Me.Kombinationsboks16 & """", ,
acWindowNormal

* * Else

* * * * DoCmd.OpenReport "Rpt_AfdelingOEE", acPreview, , "[Year] =" &
Me.Kombinationsboks7 & " And [Week] = " & Me.Kombinationsboks5 & " And
[Year] = " & Me.Kombinationsboks9 & " And [Week] = " &
Me.Kombinationsboks11 & " And [Dpt] = """ & Me.Kombinationsboks16 & """", ,
acWindowNormal

* * End If

End Sub

Thanks for your help

Ticotion


So open another query/recordset based on the first one with an
additional filter and then pass that to Excel.