1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Report on Continuous Form in Access

Discussion in 'Business Applications' started by Bradybunch, Jan 30, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    I have a continuous form of data. I then filter it to have only specific data. I then want a to click a button to display that filtered data on the report ready to print.

    I have tried in the OnClick event of the button:

    DoCmd.OpenReport "RptDataHardwarePCLaptops", acViewPreview, , acViewReport, , Me.Filter

    and also:

    DoCmd.OpenReport "RptDataHardwarePCLaptops", acViewPreview, , "HardwareID = " & HardwareID

    Hopefully somebody can show me the error of my ways

    Thanks in advance!

    Mike
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Mike, there are a couple of ways to do this, the second one you list should work providing you only want 1 HardwareID in the Report.
    You could create a query for the report and use the old query Criteria
    forms![formname]![HardwareID]
    where formname is the name of your form.
    Or you could try VBA in the Report that sets the Report filter to the same as the Form's filter.
     
  3. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Thanks for coming back to me OBP,

    I have a query which i already use for the form, so i use the same one for the report. Where would i put the old query criteria?

    Cheers
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    In the HardwareID column's first Criteria Row.
     
  5. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Okay, FrmDataHardwarePCLaptop looks at QryDataHardwarePCLaptop, with a filter in the query to filter only PC's and Laptops. On the form i have a button called Report, which is programed 'DoCmd.OpenReport "RptDataHardwarePCLaptops", acViewPreview, , acViewReport, , Me.Filter' in the OnClick Cmd and gets its data from QryRptDataHardwarePCLaptop, and in this query under HardwareID in the fisrt criteria row, i put forms![FrmDataHardwarePCLaptop]![HardwareID]

    In doing this it still does not replicate what i have on my form view when i have filtered data on the form view. Am i missing anything out?

    Cheers
     
  6. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Does the query provide the same Record as the form?
     
  7. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Yes the Query has been duplicated and renamed with QryRpt at the beggining of it. 'DoCmd.OpenReport "RptDataHardwarePCLaptops", acViewPreview i have put just this in now on the button to see if it makes a change. opening the report just displays one line, which the record selected, but i want all records which have been filter not a singular one.
     
  8. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    I did say that method would only return one ID, ie one record.
    Is the form filter variable?, if it is you may have to resort to writing in the to the Report's filter using VBA or using VBA to rewrite a Query Def.
    I have posted that version before.
     
  9. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Oh, thought you meant the code that is in the button for bringing up the report. How do you know if the Forms filter is Variable?
     
  10. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    How does the form filter work, do the users make selections?
     
  11. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Yup, its a continuous form, and its all the data for laptops and Desktops in the company. I might want to filter just on Laptops, or on the warranty expiry etc. So i will apply a filter there and then. then youll want a print out. I can print out the form view, just doesnt look as nice as a report view.
     
  12. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Well you could assign the Filter to a Public Variable and use the variable in the Open report Button's VBA code, or try using the Report's On Load event procedure to sert the report's filter to the public variable.
    Or as I said you could try writing a Query Def that replaces the query each time.
     
  13. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    The 1st options are going over my head, as i dont know what a public variable is? Also im not sure what how you write a query Def either to be honest :/ Which ever way you look at it it doesnt look simple.
     
  14. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
  15. Bradybunch

    Bradybunch Thread Starter

    Joined:
    Sep 10, 2009
    Messages:
    211
    Ive had a look at the chaps database, that you have posted. His DB looks good, however im still none the wiser with a query def. I would try anything, i like to learn...not sure if you can open my eyes to query defs?
    The form is nothing special, i just apply filter with in access to filter only certain info through the filter tool.
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1087558

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice