Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

copy filter from Form to Report

Discussion in 'Information Technology' started by Jesus Campos, Jul 28, 2006.

  1. Jesus Campos

    Jesus Campos
    Expand Collapse
    Guest

    Hi,

    I have a form and a report with the same data. On the form I active very
    times filters and I would like to pass it for report to print the same data
    of the form.

    To open the report I have

    stDocName = "form_name"
    If Me.FilterOn = True Then
    DoCmd.OpenReport stDocName, acPreview, Me.Filter
    Else
    DoCmd.OpenReport stDocName, acPreview
    End If

    But it report an error. Anyone can help me?
    Thanks.
     
  2. Loading...

    Similar Threads Forum Date
    Opinion Akal Takht concerned on drug addiction, copying during exams Breaking News Nov 5, 2013
    SciTech New Quantum Dot Technique Combines Best of Optical and Electron Microscopy Breaking News Jun 17, 2013
    India Copy of 48th Rreport of 'LOKPAL BILL 2011' Presented in Parliament Breaking News Dec 10, 2011
    Bhagats Sheikh Farid Copyright? History of Sikhism Nov 14, 2011
    Christianity Public library find is only surviving copy of rebel hymn book Interfaith Dialogues Jan 8, 2011

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    What error number is it? What does the error message say?

    Open the Immediate Window (Ctrl+G), and enter:
    ? Forms![Form1].Filter
    substituting the name of your form for Form1.
    What result do you get?

    Are there any combo boxes involved in the filter? In Access 2002 or 2003,
    this can mess up the ability to use the the filter in a report, unless you
    create a query as the source for the report and alias the lookup tables with
    the same name that the combo uses for them in the form's Filter.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Jesus Campos" <jesuscampos70@hotmail.com> wrote in message
    news:utlRMUxgGHA.4712@TK2MSFTNGP05.phx.gbl...
    >
    > I have a form and a report with the same data. On the form I active very
    > times filters and I would like to pass it for report to print the same
    > data of the form.
    >
    > To open the report I have
    >
    > stDocName = "form_name"
    > If Me.FilterOn = True Then
    > DoCmd.OpenReport stDocName, acPreview, Me.Filter
    > Else
    > DoCmd.OpenReport stDocName, acPreview
    > End If
    >
    > But it report an error. Anyone can help me?
    > Thanks.
     
  4. Jesus Campos

    Jesus Campos
    Expand Collapse
    Guest

    sorry I didn't understand, can you exemplify on this mdb example?



    Thanks
     
  5. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Please do not post attachments.
    We are not able to open everyone's database.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Jesus Campos" <jesuscampos70@hotmail.com> wrote in message
    news:OoA7hLygGHA.3956@TK2MSFTNGP02.phx.gbl...
    > sorry I didn't understand, can you exemplify on this mdb example?
     
  6. Jesus Campos

    Jesus Campos
    Expand Collapse
    Guest

    Ok, sorry!

    I did what you said, I create a query and I use it on the report and for the
    form, and now ,how I can copy the filter from the form to the report?


    PS: If you want you can send me a email and I reply to you with the mdb.
     
  7. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    The first question was:
    What error number do you get?
    What does the error message say?

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Jesus Campos" <jesuscampos70@hotmail.com> wrote in message
    news:eOCsvTygGHA.3652@TK2MSFTNGP02.phx.gbl...
    >
    > I did what you said, I create a query and I use it on the report and for
    > the form, and now ,how I can copy the filter from the form to the report?
     
  8. Jesus Campos

    Jesus Campos
    Expand Collapse
    Guest

    > The first question was:
    > What error number do you get?
    > What does the error message say?


    It's not an error, it's an input argument asking for:
    "Lookup_id__[tablename].[field_name]"



    Code of form button:

    Dim stDocName As String
    stDocName = "report_name"
    If Me.FilterOn = True Then
    DoCmd.OpenReport stDocName, acPreview, , Me.Filter
    Else
    DoCmd.OpenReport stDocName, acPreview
    End If
     
  9. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Okay, create a query, using any table(s) you need.
    Add the table that the combo gets it records from.
    In the upper pane of query design, right-click this table.
    Set its Alias property so it matches exactly the name that the argument is
    looking for.

    Once the names match correctly, the form's query will work in the report as
    well.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Jesus Campos" <jesuscampos70@hotmail.com> wrote in message
    news:uWiI$pygGHA.4712@TK2MSFTNGP05.phx.gbl...
    >> The first question was:
    >> What error number do you get?
    >> What does the error message say?

    >
    > It's not an error, it's an input argument asking for:
    > "Lookup_id__[tablename].[field_name]"
    >
    >
    >
    > Code of form button:
    >
    > Dim stDocName As String
    > stDocName = "report_name"
    > If Me.FilterOn = True Then
    > DoCmd.OpenReport stDocName, acPreview, , Me.Filter
    > Else
    > DoCmd.OpenReport stDocName, acPreview
    > End If
     
  10. Jesus Campos

    Jesus Campos
    Expand Collapse
    Guest

    It works, many thanks!


    "Allen Browne" <AllenBrowne@SeeSig.Invalid> escreveu na mensagem
    news:Oe2m36ygGHA.5096@TK2MSFTNGP02.phx.gbl...
    > Okay, create a query, using any table(s) you need.
    > Add the table that the combo gets it records from.
    > In the upper pane of query design, right-click this table.
    > Set its Alias property so it matches exactly the name that the argument is
    > looking for.
    >
    > Once the names match correctly, the form's query will work in the report
    > as well.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "Jesus Campos" <jesuscampos70@hotmail.com> wrote in message
    > news:uWiI$pygGHA.4712@TK2MSFTNGP05.phx.gbl...
    >>> The first question was:
    >>> What error number do you get?
    >>> What does the error message say?

    >>
    >> It's not an error, it's an input argument asking for:
    >> "Lookup_id__[tablename].[field_name]"
    >>
    >>
    >>
    >> Code of form button:
    >>
    >> Dim stDocName As String
    >> stDocName = "report_name"
    >> If Me.FilterOn = True Then
    >> DoCmd.OpenReport stDocName, acPreview, , Me.Filter
    >> Else
    >> DoCmd.OpenReport stDocName, acPreview
    >> End If

    >
    >
     

Share This Page