Running a report for a specific record from a form

P

Petterq

Hi.
I have a form where we put information concerning a specific item registered
on the items serial number.

We have a report based on a query that presents this information for a
printout meant for our supplier.

I would like to run the report directly from the form, taking the items
serial number from the form and putting that as a criteria for the query.
Making the report show the result only for the record presented in the form
from where I run the report.
 
D

Daniel Pineault

This can easily be done. Simply create a new button on your form and then
use the OpenForm method to open your form. In the openform input variable
specify your where clause so it use the serial number from the active record
to only return the report for that serail number.

Basic Synthax
DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

So try something like
DoCmd.OpenForm "YourReportName", , ,"[TableSerialNumberFieldName] = '" &
Me.FormSerialNumberControlName & "'"

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
P

Petterq

Hi.

I think I am on track of something, but I don't get it to work.

The orignial code is:

Dim stDocName As String

stDocName = "Mtrack-reklamasjonsskjema ETS"
DoCmd.OpenReport stDocName, acPreview


The fieldname for my variable is: "Serie-nr"

Should this result in this code?:

Dim stDocName As String

stDocName = "Mtrack-reklamasjonsskjema ETS"
DoCmd.OpenReport stDocName, [Serie-nr] = "" & Me.Serie-nrControlName &
"" acPreview

And what should I do with the query? Currently I ask for the serialnumber in
the query, so the user have to type it in.

Daniel Pineault said:
This can easily be done. Simply create a new button on your form and then
use the OpenForm method to open your form. In the openform input variable
specify your where clause so it use the serial number from the active record
to only return the report for that serail number.

Basic Synthax
DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

So try something like
DoCmd.OpenForm "YourReportName", , ,"[TableSerialNumberFieldName] = '" &
Me.FormSerialNumberControlName & "'"

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



Petterq said:
Hi.
I have a form where we put information concerning a specific item registered
on the items serial number.

We have a report based on a query that presents this information for a
printout meant for our supplier.

I would like to run the report directly from the form, taking the items
serial number from the form and putting that as a criteria for the query.
Making the report show the result only for the record presented in the form
from where I run the report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top