How to print form details to the report

chan0210

Registered User.
Local time
Tomorrow, 07:26
Joined
Feb 28, 2007
Messages
23
Hi,

I have a form that displayed my database information. these information can either be filtered by some results or left unfiltered. How can i displayed whatever that was on the form to the report?
That is to say, if it is being filtered by some results, the report should be able to display the filtered results. if it is not being filtered (all records shown), the report should be able to display likewise. How can i achieve that?
Please advise.
 
Hi,

I have a form that displayed my database information. these information can either be filtered by some results or left unfiltered. How can i displayed whatever that was on the form to the report?
That is to say, if it is being filtered by some results, the report should be able to display the filtered results. if it is not being filtered (all records shown), the report should be able to display likewise. How can i achieve that?
Please advise.

Use an OR AND statement in your query for the Record Source like:

(([Field1]=Forms!YourFormName!YourControlName Or Forms!YourFormName!YourControlName Is Null)=True) AND (([Field2]=Forms!YourFormName!YourControlName2 Or Forms!YourFormName!YourControlName2 Is Null)=True)

This will allow you to filter the record or ignore nulls. That way the report will print either all the records or a filtered set.
 
hi Wiz47,

Thanks for replying. You mean i have to include the codes at the record source? which record source? For my form, it is being filtered by 4 options and all is based on the 4 results in one field (status). so how am i going to approach using your method? i am not very clear on your steps. sorry, i am quite new to access. Please advise.
 
hi Wiz47,

Thanks for replying. You mean i have to include the codes at the record source? which record source? For my form, it is being filtered by 4 options and all is based on the 4 results in one field (status). so how am i going to approach using your method? i am not very clear on your steps. sorry, i am quite new to access. Please advise.

When you call the report (from a button on your form I presume):
Code:
DoCmd.OpenReport "Name of Your Report", acViewPreview
It will use the query named in the report as the record source.

To add the query as the recodsource in your report - open the report in design view, right-click and choose properties, then in the window that opens type the name of your query in the record source block.

If you want to add two more criteria to query simply add them with an AND between them. In the example I have two fields listed. Look carefully and you'll see that the code repeats after the AND (the only thing changing is the Field Name and Control name) You can add as many as you like.

On Edit - I didn't realize that this was based on ONE field.

If you are still having problems, attach a stripped down version of your db and I'll have a look at it.
 
Last edited:
so you are saying that this code
(([Field1]=Forms!YourFormName!YourControlName Or Forms!YourFormName!YourControlName Is Null)=True) AND (([Field2]=Forms!YourFormName!YourControlName2 Or Forms!YourFormName!YourControlName2 Is Null)=True)
i add in my query under criteria, right? and the command button of the form, i just use the open report code. am i right to say that?

For my case, i have one field call "status" and it is filtered by A,B,C or D (all within the status field), so can i repeat the field name? what do you mean by YourControlName?
 
Last edited:
I have read your message. how do i attached the db in this forum as i am new to the forum?
It seems that the forum has a problem with attaching my database, it does not allow me to attach at all.
can you give me your email so that i can mail it to you?
 
Last edited:
Hi Wiz47,

I managed to attach the slip down version of my database.
Please view and advise. Thanks alot!
 

Attachments

Hi Wiz47,

I managed to attach the slip down version of my database.
Please view and advise. Thanks alot!

I tweaked it a bit and now it is working as you wanted. Please see my PM for additional information.
 

Attachments

Users who are viewing this thread

Back
Top Bottom