Results 1 to 4 of 4
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    VBA for Print Button

    Can someone post the VBA for a click button event to print with conditions:



    If user clicks button, print dialog window opens. User clicks "Ok" to print selected record or "Cancel" to not print the selected record.

    If user prints the selected record, then new record is saved to table, Form1 closes, Form1 reopens.

    If user cancels print of selected record, then end IF.

    Thank you so much.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    To print a single record from form, form would have to be filtered to that one record. Why not print a report?

    Open the print dialog with: Docmd.RunCommand acCmdPrint


    If user is printing an existing record, what do you mean by 'save new record'?

    Why close then reopen the form?

    Duplicate thread https://www.accessforums.net/forms/p...ton-41668.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  4. #4
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    The form is bound to a table. The data entry property is also set to yes. The clerk can only see the new record they are working on. Navigation controls are all gone. User cannot see previous records. I'm going to hide the table. Once the user clicks a button here are the steps that will follow. Record will be saved, then form will go to new record, message box prompt to let user know the record has been saved, then the form will print. Once this happens it becomes concrete and the only way to delete the record will be to ask a supervisor to go into the backend table with password to delete the record. The form that is being printed is sort of like a receipt and I want to see the record of how they printed it before they handed it over to the customer. I managed to figure this one out myself. Thanks for your help anyway and here is the code I used:

    Private Sub cmdSavePrint_Click()

    If Not IsNull(Me.Clerk_Initial) Then
    DoCmd.Save
    DoCmd.GoToRecord , , acNewRec
    MsgBox "Record has been saved. To delete record, report to a Supervisor."
    DoCmd.PrintOut
    Else
    DoCmd.CancelEvent
    Beep
    MsgBox "You must enter your initials.", vbInformation, "Required Data"
    DoCmd.GoToControl "[Clerk Initial]"
    End If

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 02-12-2014, 12:49 PM
  2. Print button quick print
    By xtrareal22 in forum Reports
    Replies: 1
    Last Post: 12-11-2013, 11:21 AM
  3. Print Button
    By Meccer in forum Access
    Replies: 1
    Last Post: 03-15-2011, 07:31 AM
  4. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  5. add a print button
    By gromit95 in forum Forms
    Replies: 0
    Last Post: 08-13-2008, 07:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums