access.course - printing reports
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

access.course - Printing reports

resolvedResolved · Low Priority · Version Standard

replyReply Sat 12 May 2007, 15:48Delegate Steven said...

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

For upcoming training course dates see: Pricing & availability

replyReply Thu 24 May 2007, 10:51Trainer Richard said...

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

replyReply Thu 24 May 2007, 11:03Delegate Steven said...

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:

Prefixed Autonumbering

When using Date Type = Autonumber as a primary key, clients may require autonumbering to be prefixed with a letter.

For example, P001, where P is the prefixed letter

Instructions
Step 1. Create Field Name
Step 2. Set Data Type to Autonumber
Step 3. Within Field Property General tabsheet,
enter Format property as [backslash]P000



View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard