Set Focus

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Engineer Clement
    New Member
    • Nov 2008
    • 3

    Set Focus

    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.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. If you are actually calling a report (and not just printing the current form) your command button will call DoCmd.OpenRepor t. 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:

    Code:
    DoCmd.OpenReport, acViewPreview,, "[ReportKeyField] = " & Me![matching control name]
    if it is a number, or like this
    Code:
    DoCmd.OpenReport, acViewPreview,, "[ReportKeyField] = '" & Me![matching control name]& "'"
    if it is a string.

    -Stewart

    Comment

    Working...