Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

access.course - printing reports

Forum home » Delegate support and help forum » Microsoft Access Training and help » access.course - Printing reports

access.course - Printing reports

ResolvedVersion Standard

Steven has attended:
Access Intermediate course

Printing reports

I am using data entry forms and the customer will need a hard copy of what has been entered. Obviously forms are not really optimized to print pretty however the report I have set up prints all the records. I want to set up a command button on the form page for the data entry user to print off the report. How can I print off only the active form using reports?
Thanks Steve

RE: Printing reports

Hi Steven

Depending on your data and your experince with Access, there are probably several options to do this.

1.
There is a DATASHEET view of the form that you are entering available under VIEW > Datasheet. This will normally show all records that you are using or entering.

One way to get around the "all records" issue, is to use a Macro to open the form in ADD ONLY mode. This means that when ever you enter data, and want to print only that entered data, you can do so.

To do this, click on Macros, then create a new macro.
Use the OPEN FORM command, and then specify the form in the options below (1st option). Then go to DATA MODE, and select ADD ONLY. Save and run the macro.

Once you add the records to your form then you can use VIEW > DATASHEET for a table view to print.


2. If the above does not work for you, you might consider hacing a field that tracks each batch of form entries. For example, if you wanted to only print TODAY's entries, add a DateEntered field to the underlying table and set the default value to "=date()". This will automatically set tat field to have todays date in it. You would then setup a query that pulls only TODAYS records from the table, and then create the report from that.

If you want to BATCH enter data, and it is not based on the date entered, and is perhaps a JobNumber or something similar, you could use the same type of solution. Just add the field to the table, and then enter the variable in the field on the form when you are capturing new records.


You could still add a button to the form to activate the report, but the command button would only open the report. (unless you want to have the SQL in the macro, rather than the report tunning off a fixed query - of course you need to know SQL to do this.)

Let me know if that helps.

Regards

Richard

RE: Printing reports

Hi Richard
Some very helpful guy gave me the code to put to paste onto command button and it works every time.

The code
Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

Regards
Steve

Access tip:

Related tables

When you have related tables such as Customers and their Orders, the Customer table is the Primary table.

Open the Customers table in datasheet view and go to the Home Tab and Records group. Click on the More option and choose Subdatasheet and then click on Subdatasheet again. Now choose the related table (Orders) and click ok.

Now you can click the + symbol by each company to show the related orders.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.