Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139

    Unanswered: Printing and control background

    Hello, and Happy Holidays to all:
    I have a printing issue that perhaps someone can point me in the right direction to finding a solution. I have a report that prints off a command button on a form. The report prints as intended, however the report also prints a second page. The second page seems to be either the switchboard (which is usually the bottom window on screen, or sometimes it prints the form part of the form/sub-form on which the command button to print is located. Any thoughts as to how to keep the system from printing a random or rogue second page? This second page never shows up on a print preview.

    Second, is there any way to have the background of the control currently getting focus to change colors so the user is easily directed to where they are on the form while entering data, then switch back to normal after losing focus?

    Thanks for your thoughts!

    Larry

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Hi Larry
    As regards the printing, thats a new one on me, I've always found the preview to match up pretty closely to the printed article. Is it possible you are calling something in addition to the requested report, as part of your code?

    the second quiestion is easy to answer
    place some code in each controls on gotfocus event, and clear the code in the controls lostfocus event. A word of caution though, event scan some times get lost, or fire out of sequence.

  3. #3
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Quote Originally Posted by healdem
    Hi Larry
    As regards the printing, thats a new one on me, I've always found the preview to match up pretty closely to the printed article. Is it possible you are calling something in addition to the requested report, as part of your code?

    the second quiestion is easy to answer
    place some code in each controls on gotfocus event, and clear the code in the controls lostfocus event. A word of caution though, event scan some times get lost, or fire out of sequence.
    Well, there is not a lot of code, I'm so new at this I am limited to macros and wizards at the present time. I envoke a macro from the command button on the form that only has two lines, OpenReport (rpt_CoverSheet) Arguments being Report Name = rpt_CoverSheet, View = Print, and Filter Name and Where Condition are blank. And the second line is PrintOut, with the arguments of PrintOur being: Print Range = All, Page From = 1, Page To = 1, Print Quality = High, Copies = 1, and Collate Copies = No. The report is based on a query and the information on the report is correct.

    On the background question... then it might be best to let the background change alone? I think it would be even more confusing if the background change got out of sequence with the coursor.

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Hi Larry G,

    Here is what I have behind my CommandButton to print basically everything I want on my report, without Filtering for anything specifically:
    Code:
    Private Sub PrintPhoneReport_Click()
    On Error GoTo Err_PrintPhoneReport_Click
    
        Dim stDocName As String
    
        stDocName = "Print out this sample report"
        DoCmd.OpenReport stDocName, acNormal
    
    Exit_PrintPhoneReport_Click:
        Exit Sub
    
    Err_PrintPhoneReport_Click:
        MsgBox Err.Description
        Resume Exit_PrintPhoneReport_Click
        
    End Sub
    Now, IF you wish to pull certain information (Criteria)to be printed on your report, the next example below will show you how to do that. I do it by selecting my Dates I need on a Form. That information is passed on to the Report. The Form is based on a Query.

    Code:
    Private Sub cmdPreviewTheReport_Click()
    On Error GoTo Err_cmdPreviewTheReport_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        stDocName = "rptEAFilingReport"
               
        stLinkCriteria = "[ScanDate]>=" & "#" & Me![BeginningDate] & "# AND [ScanDate]<=" & "#" & Me![EndingDate] & "#"
    
        DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
            
        'DoCmd.OpenReport stDocName, acNormal
    
    Exit_cmdPreviewTheReport_Click:
        Exit Sub
    
    Err_cmdPreviewTheReport_Click:
        MsgBox Err.Description
        Resume Exit_cmdPreviewTheReport_Click
        
    End Sub
    Hope this helps you out some. If not I'm sure someone can maybe give you a better solution. Oh, btw, as I was a newbie once upon a time also, (still learning) I found the best way to get away from Macros and get into VBA is to create some Macros, then use the Macro to Code conversion built into A2k. Once it converts your Macro to VBA code, just read it and see what it does.

    have a nice day
    BUD

  5. #5
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Hi Bud... thanks for the reply. I'll give the code a try and let you know how it works out. And yes, about the creating VBA code from macros... I just bought the Beginning Access 2002 VBA (Wrox) book today and the very first exercise was to convert a macro to code. Pretty neet. Seemed like a whole lotta code just to make one line of it the business end of the function. Oh well, in another 1200 pages I should either have the code thing down pat, or stick to word processing (-:

    Thanks again...

    Larry


    Quote Originally Posted by Bud
    Hi Larry G,

    Here is what I have behind my CommandButton to print basically everything I want on my report, without Filtering for anything specifically:
    Code:
    Private Sub PrintPhoneReport_Click()
    On Error GoTo Err_PrintPhoneReport_Click
    
        Dim stDocName As String
    
        stDocName = "Print out this sample report"
        DoCmd.OpenReport stDocName, acNormal
    
    Exit_PrintPhoneReport_Click:
        Exit Sub
    
    Err_PrintPhoneReport_Click:
        MsgBox Err.Description
        Resume Exit_PrintPhoneReport_Click
        
    End Sub
    Now, IF you wish to pull certain information (Criteria)to be printed on your report, the next example below will show you how to do that. I do it by selecting my Dates I need on a Form. That information is passed on to the Report. The Form is based on a Query.

    Code:
    Private Sub cmdPreviewTheReport_Click()
    On Error GoTo Err_cmdPreviewTheReport_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        stDocName = "rptEAFilingReport"
               
        stLinkCriteria = "[ScanDate]>=" & "#" & Me![BeginningDate] & "# AND [ScanDate]<=" & "#" & Me![EndingDate] & "#"
    
        DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
            
        'DoCmd.OpenReport stDocName, acNormal
    
    Exit_cmdPreviewTheReport_Click:
        Exit Sub
    
    Err_cmdPreviewTheReport_Click:
        MsgBox Err.Description
        Resume Exit_cmdPreviewTheReport_Click
        
    End Sub
    Hope this helps you out some. If not I'm sure someone can maybe give you a better solution. Oh, btw, as I was a newbie once upon a time also, (still learning) I found the best way to get away from Macros and get into VBA is to create some Macros, then use the Macro to Code conversion built into A2k. Once it converts your Macro to VBA code, just read it and see what it does.

    have a nice day
    BUD

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Quote Originally Posted by Larryg
    Second, is there any way to have the background of the control currently getting focus to change colors so the user is easily directed to where they are on the form while entering data, then switch back to normal after losing focus?
    There is a way this can be done with no code at all and with a little work can look rather elegant. Simply set the BackColor of your controls to the color you would like to have in your entry boxes when each one gets focus. Then set the BackStyle of each entry control to Transparent. Each entry box will appear transparent except the one that contains focus. When focus is removed from the control, it goes transparent again.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  7. #7
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Quote Originally Posted by CyberLynx
    There is a way this can be done with no code at all and with a little work can look rather elegant. Simply set the BackColor of your controls to the color you would like to have in your entry boxes when each one gets focus. Then set the BackStyle of each entry control to Transparent. Each entry box will appear transparent except the one that contains focus. When focus is removed from the control, it goes transparent again.

    .
    Hey... that works pretty neat. Thank you !!!

    Larry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •