By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,490 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,490 IT Pros & Developers. It's quick & easy.

Set Focus

P: 3
Hi
Greetings to all the great guys responible for the up keep of this site.
In my access database, I have a form and a report.
When I fill the content in the form, I did like to print it out in the report. On the form, I created a print button and but I am having it difficult to set the focus on the report to print only the form I am on or rather just filled.
What do I do.
Nov 6 '08 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
Hi. If you are actually calling a report (and not just printing the current form) your command button will call DoCmd.OpenReport. You can restrict the report to the current record by adding a WHERE clause to the OpenReport (which is like an SQL WHERE clause but missing out the keyword WHERE). You would need to have a common key field in the recordsource of your report and the recordsource of your form, one whose value you can pass from a control on the form to the WHERE clause, like this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport, acViewPreview,, "[ReportKeyField] = " & Me![matching control name]
if it is a number, or like this
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport, acViewPreview,, "[ReportKeyField] = '" & Me![matching control name]& "'"
if it is a string.

-Stewart
Nov 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.