Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2005, 09:02 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing Report's RecordSource !

Hi !
Have a form used as criteria to preview a report which recordsource
should be settled by the values on the form. Although when asked
to be showed the report prompts again to the values that were
on the criteria form. What am i doing wrong ? How would i have
the report taking the values on the form as criteria and not
asking again to the same values ?
Any help will be welcome.
Regards Penta.:(

 
Old April 25th, 2005, 11:27 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   It sounds like your report is based on a query that you have set criteria prompts on. If this is so, remove all the criteria from the query that your form is passing. Since the form passes them, you don't need them in your query. Your query will continue to prompt for the criteria unless you remove them. Just pass them with the form.

HTH

mmcdonal
 
Old April 25th, 2005, 12:01 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks mmcdonal for ur care,
U have had a good idea of what i have. Problem is how do i relate the form
with the query. What i have is code on the On_Open report that opens the
criteria form. I fill the criteria controls on the form, click a button
that should continue loading the report meanwhile hiding the form. I've
tried ur suggestion but it seems that some code is missing to relate the
criteria form to the recordsource query of the report.
Any other suggestion will be great.
rgds p.

 
Old April 29th, 2005, 08:20 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Penta, the trouble is mmcdonal's suggestion is based on the way we "normally" open a report. Normally we open the form to request the criteria and provide a button on that form to request the report. The button executes a DoCmd.OpenReport with the appropriate parameters.

I'm assuming that your setup is something like this: Your query has criteria set as something like

= [Forms]![formname]![fieldname]

When the report opens, your form pops up, you enter the information and do something to allow the report to continue processing. This doesn't make sense because unless your form is opened Modal, the code in your On_Open of the report will continue processing as soon as the report is opened (without waiting for you to input your criteria). If your form is Modal, you'll have to close the form before the report can continue processing. And if you close the form, the query can't gain access to the fields on the form.

Your way may work. But I'm afraid that your report is going to start trying to use the query before you have a chance to open your form. I think that's why you get the prompt twice.

I suggest you try opening the form and have the form open the report.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old April 29th, 2005, 08:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I was assuming that he was opening the report by passing parameters from the form, since he states:

   "Have a form used as criteria to preview a report which recordsource should be settled by the values on the form."

I also assumed that when he built the query originally, he put in parameter prompts, since he states:

   "Although when asked to be showed the report prompts again to the values that were on the criteria form."

In this case, you open the form, select the criteria, and then pass those criteria to the report, which passes them to the underlying query. Therefore no prompts are needed, unless you want the user to select criteria when they open the report using the queries criteria prompts.

So there is nothing wrong with my suggestion in this case. My suggestion assumes that penta

    "...try opening the form and have the form open the report."



mmcdonal
 
Old April 29th, 2005, 08:43 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hence my comment:

   "Just pass them with the form."

mmcdonal
 
Old April 29th, 2005, 08:53 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Isn't that what I said???
 
Old April 29th, 2005, 09:00 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes, and it's what I said as well. So why was it wrong when I said it and not wrong when you said it?


mmcdonal
 
Old April 29th, 2005, 09:38 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Upon reflection it occurred to me that you might have interpretted my message that way. I'm sorry.

I was trying to explain to penta that you gave the right answer, an answer similar to what I would have given, given the information in the original question. Since penta came back with the information about the On_Open for the report, I understood why your answer wasn't working for him and wanted him to understand why you gave the answer you did.

I am sorry for the misunderstanding. I certainly did not mean to slight you or your answer.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old April 29th, 2005, 10:09 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

No worries. I couldn't understand the difference between the two solutions. I assumed penta was doing what we were suggesting.

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Array as recordsource for Report prasanta2expert Access VBA 1 March 14th, 2008 04:21 PM
Access Subform RecordSource Issue llaurit Access 3 March 12th, 2008 01:04 PM
Recordsource Scripts82 Access VBA 4 March 7th, 2006 03:04 AM
How to change report's objects dynamically. Vadim Crystal Reports 2 May 17th, 2004 09:40 AM
Report's record source too long Mitch Access 7 January 26th, 2004 04:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.