Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I got it to print. YOu may need to format the report a little. It seems to want to print two pages. What you need to do.....

    Remove the name of the macro from the click event for your control.
    Save the database by clicking the "Save" icon
    Go back to the click event for your control and click the elipses (...)
    Select "Code Builder" from the prompt window.

    The VBA editor should open and the cursor should be within the Click event handler for your control.
    Replace the code in the middle of the handler.


    Just below

    Private Sub cmdPrintC5_Click()
    On Error GoTo Err_cmdPrintC5_Click

    and before

    End Sub



    paste the following code and save your DB
    Code:
         Dim stDocName As String
        Dim strWhere As String
        strWhere = "[MailingListID] = " & Me.MailingListID
    
        stDocName = "rptPrintC5env"
        DoCmd.OpenReport stDocName, acNormal, , strWhere
    Exit_cmdPrintC5_Click:
        Exit Sub
    Err_cmdPrintC5_Click:
        MsgBox Err.Description
        Resume Exit_cmdPrintC5_Click

  2. #17
    Ally1205 is offline Advanced Beginner
    Windows 7 64bit Access 2000
    Join Date
    Jul 2013
    Posts
    68
    ItsMe..... Brilliant! Thank you!! the button works on both forms now. After I coded the button on the first form, per your instructions, I copied the entire page of coding and pasted it into the button on the second form, and found that both buttons, on both forms work! That's what I wanted!! I still don't understand why it didn't work on both forms before.

    Yes, there is indeed an issue with the report wanting to print to pages. That's another problem I have not been able to solve yet.

    What I am going to do now, is try and get the other two printing buttons to work on both forms....

    Thanks again!
    Ally1205

  3. #18
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Be careful copying all of the code from one procedure to another form's module. There is a reason I mentioned pasting the code a certain way. You want to avoid pasting the first and last lines in an event handler for a control.

    These lines act as containers and it is onside these containers you want your code to go. If Access does not recognize the container, it will behave in a peculiar way. I recommend using the ellipses button in the Event tab of the controls properties pane to create a Sub Procedure to handle events.

    As for why your DB was not working correctly, I do not know specifically. I did not look into it. I believe it is because of the where criteria you defined within the Macro. My preference is to manage this criteria at the form level. The code you pasted works because yesterday you removed the filter criteria from the report and today you removed the Macro. The criteria is now managed by the code you pasted.

  4. #19
    Ally1205 is offline Advanced Beginner
    Windows 7 64bit Access 2000
    Join Date
    Jul 2013
    Posts
    68
    ItsMe..... Brilliant! Thank you!! the button works on both forms now. After I coded the button on the first form, per your instructions, I copied the entire page of coding and pasted it into the button on the second form, and found that both buttons, on both forms work! That's what I wanted!! I still don't understand why it didn't work on both forms before.

    Yes, there is indeed an issue with the report wanting to print to pages. That's another problem I have not been able to solve yet.

    What I am going to do now, is try and get the other two printing buttons to work on both forms....

    Thanks again!
    Ally1205

  5. #20
    Ally1205 is offline Advanced Beginner
    Windows 7 64bit Access 2000
    Join Date
    Jul 2013
    Posts
    68
    I have now got the other buttons working too. As I prefer the report to open in preview mode, I deduced (after googling) that I needed to change:

    acNormal
    to
    acViewPreview

    It seems to work.... I've also solved the 2-pages-being-printed oddity.... I just had to experiment with changing the positions of the page edges in each report's design mode. I didn't understand what I was doing exactly, but trial and error prevailed, anyway! These problems have been dogging me for months... I'm so glad to have got them sorted at last (with your help, that is)!

    Kind regards,
    Ally1205

  6. #21
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    This code does not belong
    Exit_cmdPrintC5_Click:
    Exit Sub

    Everything else looks good though

    It should probably look like this

    Code:
    Private Sub CmdPrintDLenv_Click()
     On Error GoTo Err_CmdPrintDLenv_Click
    
    Dim stDocName As String
    Dim strWhere As String
        strWhere = "[MailingListID] = " & Me.MailingListID
    
        stDocName = "print Dl envelop"
        DoCmd.OpenReport stDocName, acNormal, , strWhere
     
     Err_CmdPrintDLenv_Click:
        MsgBox Err.Description
        Resume Exit_CmdPrintDLenv_Click
    
     End Sub
    This is the code that is doing the work

    Code:
    Dim stDocName As String
    Dim strWhere As String
        strWhere = "[MailingListID] = " & Me.MailingListID
    
        stDocName = "print Dl envelop"
        DoCmd.OpenReport stDocName, acNormal, , strWhere
    The other code is error handling that is specific to the control's name. So this part of the code is not interchangeable between controls with different names.

  7. #22
    Ally1205 is offline Advanced Beginner
    Windows 7 64bit Access 2000
    Join Date
    Jul 2013
    Posts
    68
    Yes; I spotted my mistake, and altered my previous reply, but apparently you had already seen it. Sorry about that.
    Everything is working perfectly now...
    Thank you again for your help!

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

Similar Threads

  1. Replies: 3
    Last Post: 06-05-2012, 01:47 PM
  2. Replies: 3
    Last Post: 07-13-2011, 02:04 PM
  3. Opening Access 2000 file in Access 2010
    By Jacob in forum Access
    Replies: 10
    Last Post: 02-12-2011, 06:56 AM
  4. Opening Database between 2007 and 2000
    By jo15765 in forum Access
    Replies: 19
    Last Post: 11-21-2010, 06:46 PM
  5. Report trouble in Access 2000
    By blago in forum Reports
    Replies: 13
    Last Post: 09-16-2010, 07:12 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