Help with reports...

andrewwood

New member
Local time
Yesterday, 16:32
Joined
Jan 31, 2007
Messages
7
Basically you could write my knowledge of Access on a postage stamp.
:D

Here goes anyway...

I've set up a database that contains all my workstations and I would like to set up a feature so that I could print off a report for each indivual workstation. I've created a report function but It seems to print all my workstations rather that just one.

Is it possible to setup a command box or prompt that would pop up and ask me to enter a machine ID number to print?

Hope I've explained this well enough.

Thanks for you help.

Andrew.
 
Thanks for that

But I may need a slight prod in the right direction to find that :D
 
But I may need a slight prod in the right direction to find that :D


Prod
Search box at top of page enter stLinkCriteria :D

There are hundreds of posts here on this subject - also search on single record. Tip - Use advanced search, search on titles only
 
Thanks again for that

...but Im a proper newbie when it comes to anything access related.

I will keep trawling through it all and see if I can use any of it, but it looks like a load of coding to me (of which means nothing :eek: )

Thanks.

Andrew.
 
Okay
it's all about properties.
What you need to do is place some code in the OnClick Event of your command button.

You will hopefully have a unique identifier attached to your record. Usually this is an autonumber generated by Access and it is often the primary Key for the table.

We'll use one table only for this example although a query can take data from numerous tables.
Say your table contains these fields

RecordID (Autonumber)
RecordName (Text)
Something else (text)

You will place all these fields on your form and on your report.

Your form – let’s call it “frmStuff” should be bound to a query, that means you use a a select query to find the data in the table for your form, and that query (call it qryStuff) is the recordsource for your form. Look in the properties of your form!



Your command button called “cmdPrintReport” will need to reference the unique number to tell the report “rptStuff” only to print the current record.

So your On Click code will be:

Private Sub cmdPrintReport_Click()
On Error GoTo Err_cmdPrint_Click


DoCmd.OpenReport "rptStuff", acNormal, "", "[RecordID]=[Forms]![frmStuff]![RecordID]"


Exit_cmdPrint_Click:
Exit Sub

Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub

Chgange the names to suit yours and bingo your rport will only have the record you were looking at and it will contain the fileds specified
 
Thank you so much for your help.

Mucho apricho :D


No sweat.

As a matter of interest if you want to see the report before printing change to
DoCmd.OpenReport "rptStuff", acPreview, "", "[RecordID]=[Forms]![frmStuff]![RecordID]"

You may need to add a command to minimize the form you're on first if the report pops up behind the form. i.e.

Then you could put a Maximize command referring to the original form in the on Close event of your report, to get you back to your form.

DoCmd.Minimize
DoCmd.OpenReport "rptStuff", acPreview, "", "[RecordID]=[Forms]![frmStuff]![RecordID]"

Then you could put a Maximize command referring to the original form in the on Close event of your report, to get you back to your form. Play around with it it's the only way to learn.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom