Report on Continuous Form in Access

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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
 

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.
 

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
 

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
 

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.
 

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.
 

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?
 

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.
 

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.
 

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.
 

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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top