From a form to a report!

tpickles1984

Registered User.
Local time
Today, 05:50
Joined
Feb 5, 2003
Messages
19
Hi, just wondering whether anyone can help me with this. I have a simple form that contains details for a component, and a subform showing what harnesses contain this component. What I'd like to be able to do is click on a button on the form, and for it to print a report showing the data on the form (ie. one component and the harnesses that it is used in).

I've made a report that should do the job, but the problem is that at the moment it shows records for all of the components, not just the one that is being viewed in the form. Ideally I'd like the button on the form to open the report and apply a filter based on the form information, just like can be done automatically when moving from one form to another.

Can anyone help with this? I've attached a sample of what the problem is at the moment, if someone could show me a way of applying the filter in this situation I'd be much obliged!
 

Attachments

You need to restrict the list of data the report shows using the field on your form "GI Number" (I have renamed it txtGINumber). Please note some of your text boxes have the same name as the underlying database fields this can cause problems. The best solution is to open in edit mode all your text boxes and the add "txt" as a prefix, also take the opportunity to remove all spaces from the text box names. I have attached your database with a modification which hopefully should fix the problem.
 

Attachments

Don't forget to save the record imediately prior to the OpenReport Method if necessary.

Code:
If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
End If
 
Thanks Tony, that seems to have done the trick! Definitely a big improvement on the manual entry I had to use before. Also thanks to Pat, above and beyond the call of duty yet again I see!
 
Just trying to head off the next question because if you weren't saving, the question was coming :) It's a little detail that way too many people forget.
 
Pat Hartman said:
It's a little detail that way too many people forget.

Well I for one will never ever foget it now!!! :o
 
Yes, that's a very good point. I've just recently had a query that didn't work because I wasn't updating the form properly; it's so easy to do if you're not on the ball!
 

Users who are viewing this thread

Back
Top Bottom