Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Arlington, Texas, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing current form (Access 2000)

    I have inherited a database that needs some updating. One of the things that I would like to improve is the quality of the form that is printed from a Record in Form view. Currently the print request just makes a copy of the Form used for input or viewing. Is there a way to print the current form as a report from a command button on the form itself? The form uses the table as its source instead of using a query to modify or add records (I will be changing this), but is there a short term fix, and can it be modified once I make the changes to the add/modify procedure?

    Thanks in advance-
    shihalud

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Printing current form (Access 2000)

    You will need to create a report that you can invoke from the command button. Most forms for data entry or display don't print well anyhow, so we generally create a report that is structured somewhat like the form, but designed specifically to print. Once you have the report (it can be based on the same data source as the form), you can use the command button wizard to open the report in preview mode or print, and specify a filter that selects the record currently displayed on the form. Hope this helps.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Arlington, Texas, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current form (Access 2000)

    Thanks for your help. Below is what I wrote for this command button that I placed on the form that I want to print:

    Option Compare Database
    Option Explicit

    Private Sub Command_49 Click ()
    Dim strDocName As String
    Dim strFilter As String

    strDocName = "rptReservation"
    strFilter = "ID = Forms![Event Reservation]!ID"
    DoCmd.OpenReport strDocName, acViewNormal, , strFilter
    End Sub

    But when I execute this, I get the entire database instead of the record that is active on the screen. What did I do incorrectly?
    thanks again - shihalud

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current form (Access 2000)

    Hi shihalud

    Try

    strFilter = "[ID]=" & Me!ID

    HTH

    John

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing current form (Access 2000)

    Try this instead:

    <pre>strFilter = "ID = " & Forms![Event Reservation]!ID
    DoCmd.OpenReport strDocName, acViewNormal, , strFilter</pre>


    That assumes that the value in the ID control is a number. If it's text, use this instead:

    <pre>strFilter = "ID = '" & Forms![Event Reservation]!ID & "'"</pre>

    Charlotte

  6. #6
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Arlington, Texas, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current form (Access 2000)

    Thanks for your help, at first it didn't work it kept printing a blank report. I added the following and it works.

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    is this because I was trying to print a record that was not yet part of the database.

    thanks shihalud

  7. #7
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Arlington, Texas, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current form (Access 2000)

    Thanks for your help

    shihalud

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing current form (Access 2000)

    The correct way to write that for the later versions of Access (i.e., Access 97 and above) is this:

    If Me.Dirty = True Then
    DoCmd.RunCommand acCmdSaveRecord
    End If

    The wizards may still be writing Access 95 code, but that doesn't mean you have to. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

Posting Permissions

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