access to a report in a specify register

  • Thread starter Thread starter geck0
  • Start date Start date
G

geck0

Guest
hi, i have a form to insert data of people, and a report to print this data in a beatiful way.So i put a button in the form to access the report, but everytime i access the report it go to the first register, and not the register i have selected in the form.So i can't print directly te report from the form, or just preview the report from the form.
Is there any way to do that? to open the report in a specify register?
Thanks.
 
You can use OpenArgs to pass a filter from the form to the report
 
well, my Knowledge about access is some poor, so really i don't know how to make these 2 things,so thank you very much guys, but a larger explain will be pleased, or just a web where these 2 things where explained.

thanks again
 
Create a command button on a form use the wizard. Specify that the command button will open a report.

it will generate a code that looks like this:



Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String

stDocName = "MyReport"
DoCmd.OpenReport stDocName, acNormal

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub


--Then modify it to look like this:



How can I print only one record using a report?

Use the OpenReport's Where condition to specify your record. For example, the following code placed behind a command button on the form would use the CurrentRecordNow control on the form to restrict the Report to only one record.

Dim stDocName As String
Dim stWhere As String
strDocName = "rptSomeReport"
strWhere = "[CurrentRecordNow]=" & me!CurrentRecordNow
DoCmd.OpenReport strDocName, acPreview, , strWhere



so your code will look like

Dim stDocName As String
dim stWhere As String

stDocName = "MyReport"
strWhere = "[CurrentRecordNow]=" & me!CurrentRecordNow
DoCmd.OpenReport strDocName, acPreview, , strWhere



[CurrentRecordNow] the name of the textbox of the current record.
 
thanks a lot liv!, problem solved..
but it works for me with : me![CurrentRecordNow] in strWhere
so was :

Dim stDocName As String
dim stWhere As String

stDocName = "MyReport"
strWhere = "[CurrentRecordNow]=" & me![CurrentRecordNow]
DoCmd.OpenReport strDocName, acPreview, , strWhere



[CurrentRecordNow] the name of the textbox of the current record.
 

Users who are viewing this thread

Back
Top Bottom