othonas
07-16-2000, 02:59 PM
Hi to everyone, i am new in access area and i appreciate if you help me with this problem. I create a command button in a form to preview some report. I want to preview the same record number in my report as it is in my form. for example 3rd record in form>>>3rd record in report.Any suggestion? Thanks
Carol
07-16-2000, 07:40 PM
Put the following code in the On-Click of your Preview button:
Private Sub Preview_Click()
On Error GoTo Preview_Click_Err
DoCmd.Save acForm, "MyForm"
DoCmd.OpenReport "MyReport", acPreview, "", "[IDField]=[Forms]![MyForm]![IDField]"
DoCmd.Minimize acForm, "MyForm"
Preview_Click_Exit:
Exit Sub
Preview_Click_Err:
MsgBox Error$
Resume Preview_Click_Exit
End Sub
Change the names accordingly. I have used Preview as the name of your command button.
Your IDField on both the form and the reports should be the primary key field.
Good luck
Actually, I think the syntax for the Open report command would be:
DoCmd.OpenReport "MyReport", acPreview, "", "[IdField] = " & [Forms]![MyForm]![IdField]