Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print only the current record 2

Status
Not open for further replies.

khwaja

Technical User
Aug 27, 2001
431
AU
What is the best option to print only the current record of a form when user does not have access to full menu or has run time access? I tried usuing wizard to create a command button on the form but this prints all records and not just the record I want. Ideally, it should print selected record stratightaway or alternatrively, it should open a print dialogue box for user to indicate print range. Look forward getting some help.

Cheers
 
Have a button on the form called cmdPrintThisPage and have the On_Click event look like :-

Private Sub cmdPrintThisPage_Click()
DoCmd.PrintOut acSelection
End Sub



QED.

G LS
 
Something else to consider:-

Do you want to ensure that the data on the form is 'current', ie has been saved to the table, before you print?

Use this as first line of On_Click event to save the data if it is useful :-

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

This is more appropriate than a simple DoCmd.Requery because requery resets the record counter to the first record. ( Which you don't want. ) The code above does a save by retains the record pointer.



'ope-that-'elps.

G LS
 
Thank you veru much guys. I blended the both approaches and result is great. Just one more question - are you aware that people without full license of MS Access can use print dialogue box and if so, how could we invoke this using a command button.

Cheers

 
I thougt we resolved this but I guess it is not doing what I expected. Using the code, it prints but only the first record. Even if I have saved a series of records, when I hit the command button, it actually goes to the first record and prints.

Is there any way we can set the printing to current record?

Cheers
 
You need to SELECT the "current" record before you can print just IT using Smudgie's code.

However, I'd caution against printing a "form" record.

The easier way to do this is to
1) write a query to select the current form record (using a criteria refering to the form's key field)
2) write a report that uses this query.
3) Stick a command button on the form to print the report.


This is a 'better practice' than allowing a user to 'print' a form, in many ways not the least of which is the reinforcement of the idea that forms are for screens and reports are for printers.

Jim
Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
I fully agree with you that report should be used in similar situations. But I find it rather difficult to figure out how to achieve what I want to achieve. In my case, I have a number of project managers who open their screen through a parameter query. Once they are there, they can save and print a purchase order relevant to their project through a command button which takes them to the PO form which is linked to that projects's key. Whole things works very well as user is able to create a PO, save it for record and then print it. Question is where could be the report option used which is basically independant of the criteria I used to link main form and the PO.

If I can invoke the print menu somehow, this may possibly solve the problem as user can indicate the record that needs to be printed. Any thoughts?

Cheers
 
Why not a combo box full of Projects and PO/s for same, limted by Project Mangler, er, sorry, MANAGER, so s/he sees only her/his projects. S/he picks a Project/PO pair, you have a report that uses a query that uses that combo pick.

Voila. Neat, sweet and petite.

Jim (sorry for the typo. I'm eating my dinner and the KFC is slipperyyyyyyyyyyyyyyyyy)

Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top