Results 1 to 9 of 9

Thread: Printing

  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Printing

    I have a form that is used to view data in an underlying table. On the form is a button, that when clicked, is supposed to print out the current form. I use the following code:
    PHP Code:
    Private Sub Cmd_Btn_Print_Form_Click()

    On Error GoTo Err_Cmd_Btn_Print_Form_Click

    Dim response
        response 
    MsgBox("Are you sure you want to print?"vbYesNo"Print?")
    If 
    response vbNo Then GoTo Exit_Cmd_Btn_Print_Form_Click

    Dim strRecNo 
    As String
    strRecNo 
    Me.CurrentRecord
    DoCmd
    .PrintOut acPagesstrRecNostrRecNo

    Exit_Cmd_Btn_Print_Form_Click
    :
        Exit 
    Sub

    Err_Cmd_Btn_Print_Form_Click
    :
        
    MsgBox "Error " Err ": " Error$
        
    Resume Exit_Cmd_Btn_Print_Form_Click
     
    End Sub 
    When I open the form regularly, then press the button, it won't print. But if I open the form in Shift-bypass mode and click the button, it works (which I cannot even begin to try and give an explanation for).

    Also, if I open the form regularly, I can press the button, and it won't work, but I can do the File > Print, then select print the Selected Record(s) radio button, and then it will print.

    FYI, the "no" option on the msgbox works.

    Can anyone give me any advice here? Anything helpful would be appreciated.
    Me.Geek = True

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Do you have a spectacular reason for not using a report instead?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    And, if you have a good reason for using a form instead of a report, use a seperate form (the user doesn't need to see it).
    Last edited by tcace; 08-21-06 at 16:11.

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    The reason I use a form is because the form can also be used to edit the information (after a security check and all that good junk).

    What do you mean by
    use a seperate form (the user doesn't need to see it).
    Thanks for the help.
    Me.Geek = True

  5. #5
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Why can't you just make a report that grabs the stuff from the current information on the form? Then make a button that calls that form and automatically prints it [using button wizard]?

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Uh, the paper printout can be used to edit the information?

    If not, create a report that mirrors your form and pulls current information from it for its datasource.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    Why, I don't know, but this fixed the problem;
    PHP Code:
    Dim strRecNo As String
    strRecNo 
    Me.CurrentRecord
    DoCmd
    .GoToRecord acDataForm"Frm_View_EWORF"acGoTostrRecNo
    DoCmd
    .PrintOut acPagesstrRecNostrRecNo 
    Me.Geek = True

  8. #8
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    What I mean is, quite simply, copy and paste the form to a new object in your DB, strip all the code and stuff out and use that as the "printable" version. The user won't see and doesn't care if the object that prints is not the same object open on the screen - they only care if the data or printed format is not correct.

    As the developer, you tie your hands if you try to make your GUI and your printed output the same object. By seperating them, you have the freedom to build controls into the GUI and format it to fit the screen while formatting the output to fit paper.

    To Teddy's point, you can create a report and then copy and paste all of the formatted stuff from the form into the report. Use the form to enter/edit info and the print button calls the report, which is suited for printing.

  9. #9
    Join Date
    Apr 2009
    Posts
    6

    Exclamation Linking Access Reports to VB.net forms

    Hello everyone

    this thread has been very useful. My problem is how do i Link the button on the vb.net to my report created in access.

Posting Permissions

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