Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    I will cut to the chase. Try converting the macro. If you programmed one in VBA but created the button with the Wizard because lets say you wanted the cool print icon Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	946 Bytes 
ID:	31928 on the button then there may be a macro and VBA coding for your print button. Just convert and remove duplicate print if did what I described or modify the resulting macro conversion, otherwise if you did it all manually then please disregard my nonsense.



    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	15.3 KB 
ID:	31927

  2. #17
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    BTW the following is what I have in VBA (Alt F11) just for reference and search for something that says "Print" or some other variant of the term.

    ORIGINAL (no warning about printing everything without a selected record):

    Private Sub btnPrint_Click()
    On Error GoTo btnPrint_Click_Err
    DoCmd.RunCommand acCmdPrint
    btnPrint_Click_Exit:
    Exit Sub
    btnPrint_Click_Err:
    Beep
    MsgBox Err.Description, vbOKOnly, ""
    Resume btnPrint_Click_Exit
    Exit Sub
    End Sub

    NEW (warns about blank form and how everything will be printed and handles the RunCommand error that pops up if the print operation is cancelled):

    coming soon...

  3. #18
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    Discovered something interesting while I am modifying my database as well. If I do not have a record selected for printing (i.e. my form is blank) then when I press the print button and click print ok button then all records associated with that form print at about 70-90 pages per minute

    Other than that my printing function works fine. Good thing I tried printing with no record so now I know a handler is required to prompt a warning message about that feature, as it is a feature if you simply want to print all records for a given form and time is an issue. Essentially it becomes the easy button.

    I updated the print code in #17 to handle the warning and the error produced if the print is cancelled.

  4. #19
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    You would normally check for no data in the reports NoData property, which will let you simply cancel out of opening the report / let you put a message box up.

  5. #20
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    Applies to response #17

    NEW (warns about blank form and how everything will be printed otherwise prints selected record):

    Create a report for each of your forms and name each one something like rptPrintNameInfo then copy all fields from your form that is associated with the report and paste into the report. While in Design View for the report, check the box in the upper left corner (where the horizontal and vertical rulers meet). On the Property Sheet under the Data tab set the Record Source to the table that holds the information for the form associated with this report.

    "rptPrintNameInfo" is whatever report name you want the current data to print to its format.

    "[IDNum] = """ & Me![txtIDNum] & """" is whatever field you want the print operation to evaluate in the form. Note there are extra quotation marks because it is a string field being evaluated in this example. The important information here is this form text box field should be unpopulated when no record is selected and populated when a record is selected because this text box field is being evaluated in order to determine what action to perform from the code listed below. The [IDNum] is the bound column name (i.e. record source) of that field. The Me![txtIDNum] is whatever the descriptive name is associated with the form's text box field being evaluated, which is located in Property Sheet > Other tab > Name field.

    Private Sub btnPrint_Click()
    On Error GoTo btnPrint_Click_Err
    Dim Response As Integer
    Dim Cancel As Integer
    If Me.NewRecord Then
    Beep
    Response = MsgBox("No record selected for printing. " _
    & vbCrLf & "" _
    & vbCrLf & "All records for current view will print if you proceed - click OK. " _
    & vbCrLf & "" _
    & vbCrLf & "Stop the print operation if you do not desire all records - click Cancel.", vbOKCancel, "Warning")
    If Response = vbOK Then
    'print every record associated with the current form in accordance with report layout
    DoCmd.OpenReport "rptPrintNameInfo", acViewNormal
    Else
    'cancel the print operation
    Cancel = True
    End If
    Else
    'print only the selected record of the current form in accordance with report layout
    DoCmd.OpenReport "rptPrintNameInfo", acViewNormal, , "[IDNum] = """ & Me![txtIDNum] & """"
    End If
    btnPrint_Click_Exit:
    Exit Sub
    btnPrint_Click_Err:
    Beep
    MsgBox Err.Description, vbOKOnly, ""
    Resume btnPrint_Click_Exit
    End Sub
    Last edited by SierraJuliet; 01-07-2018 at 05:17 AM.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Printing of separate record
    By Erictsang in forum Forms
    Replies: 5
    Last Post: 11-12-2017, 11:25 PM
  2. Printing to PDF (only need 1 record)
    By lccrews in forum Forms
    Replies: 1
    Last Post: 08-25-2017, 12:20 PM
  3. Printing specific record
    By mike23 in forum Forms
    Replies: 5
    Last Post: 04-05-2014, 08:41 AM
  4. Replies: 0
    Last Post: 05-25-2011, 06:13 AM
  5. Printing the active record only
    By aligahk06 in forum Access
    Replies: 3
    Last Post: 12-02-2010, 08:22 PM

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