Excel and filter

T

Ticotion

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
 
P

pietlinden

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 onlythe
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.
 

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