Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Easy Report Q (2k)

    I created a basic report that displays information from a form in an easy to read format for printed copies. On my form there is a "Print Screen" button that prints out the report for the particular record the user is looking at. However my report is based off of my form, so it prints a report for each record in my table. For some reason, I can't remember how I used to filter it so that only the report I was looking at was printed out, but I remember doing this a few months ago, anyone know how to do this?
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  2. #2
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    If you just want to print one form record click the record selection bar on the left of the form to select the single record then choose File Print. Choose the selected records optionin the print dialog box.
    Carla

  3. #3
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    I would use that for sure if I was the one using it, but I don't trust my user's knowledge of access to do that (the record bar is actually disabled). I was heading towards the direction of an automated button, I just can't remember how I made sure that only one record was printed.
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Easy Report Q (2k)

    You need a field that identifies the record, say RecordID. Use code like the following for the button:

    Private Sub cmdPrint_Click()
    DoCmd.OpenReport "rptMyReport", acViewPreview, , "RecordID = " & Me.RecordID
    End Sub

    This will open the report with only one record in preview mode. Replace acViewPreview with acViewNormal to print the report without previewing. If the ID field is a text field (I assumed it was a number field above), use

    ..., "RecordID = " & Chr(34) & Me.RecordID & Chr(34)

  5. #5
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    well there is a seperate preview report button that I'm using. The print report button isn't going to show the report at all, its just going to print it out, does that make sense?

    and then i guess i would use something like:

    Private Sub cmdPrint_Click()
    DoCmd.PrintReport "rptMyReport", "DrawingNo = " & Me.DrawingNo
    End Sub

    where DrawingNo is my primary key field

    that look right?
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    Like Hans say if you want to print without preview use :
    Private Sub cmdPrint_Click()
    DoCmd.PrintReport "rptMyReport", acViewNormal, , "DrawingNo = " & Me.DrawingNo
    End Sub
    If you want to have a preview use:
    Private Sub cmdPrint_Click()
    DoCmd.PrintReport "rptMyReport", acViewPreview, , "DrawingNo = " & Me.DrawingNo
    End Sub
    Pay attention to the two commas before "DrawingNo ="
    Francois

  7. #7
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    I'm doing that now, but its not filtering... I'm not sure why. The field is a text field. Here is my exact code (I tried using both 1 comma and 2 commas after acViewNormal):

    Private Sub Command241_Click()
    On Error GoTo Err_Command241_Click

    Dim stDocName As String

    stDocName = "Checklist"
    DoCmd.OpenReport stDocName, acViewNormal, "[DWG_NO]=" & Chr(34) & Me.DWG_NO & Chr(34)

    Exit_Command241_Click:
    Exit Sub

    Err_Command241_Click:
    MsgBox Err.Description
    Resume Exit_Command241_Click

    End Sub

    I saw that print record uses acSelection to print a single record, but I'm not sure that applies to printing reports. Does the report itself need to have a filter in it?
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    You have to use two commas.
    Is the field [DWG_NO] on the report ? If not, add it to the detail section and if you don't want it appear on the report set his Visible property to No
    Francois

  9. #9
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    DWG_NO was in the header of the report, and I just added it to the details section as well. I also made sure that there were 2 commas before "[DWG_NO]="... and it still didn't work [img]/forums/images/smilies/sad.gif[/img]

    I don't understand why this won't work, it tries to print out all 2500 records everytime.
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  10. #10
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    I'm out of ideas. Can you attach a stripped version of the db ? See <post#=401925>post 401925</post#> for instructions how to make it under the 100k limit.
    I have to leave now. If nobody has looked at it when I return, I'll have look.
    Francois

  11. #11
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    Well I think I know what my problem may be...

    I made a button to view the report, and to filter the results to the single record that the user is currently viewing. But when I try to apply the filter, nothing seems to happen. The report's control source is the same as that of the form, so I don't know why this isn't working. I am using Han's method for opening the report, but no filter seems to be applied.

    <img src=/S/bash.gif border=0 alt=bash width=35 height=39> any <img src=/S/bash.gif border=0 alt=bash width=35 height=39> more <img src=/S/bash.gif border=0 alt=bash width=35 height=39> suggestions? <img src=/S/bash.gif border=0 alt=bash width=35 height=39>
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  12. #12
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Easy Report Q (2k)

    Is DWG_NO numeric? If so, then you don't need the Chr(34)'s.
    Failing all that, why don't you post your database with just the relevant bits compacted and zipped.

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Easy Report Q (2k)

    See Francois' suggestion to post a stripped down copy of the database.

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

    Re: Easy Report Q (2k)

    You aren't applying a filter, you're trying to pass a where condition to the report you're opening so that it will open/print with only the specified record in its recordset. Is the report already open when you try this? If so, make sure it's closed first.
    Charlotte

  15. #15
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Easy Report Q (2k)

    Here is an example i made real quick, if you still aren't sure what I mean to do, please ask! and thanks to everyone whos trying to help! i appreciate it.

    i had to make an example because there are too many controls to strip off of the other one <img src=/S/drop.gif border=0 alt=drop width=23 height=23>
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

Page 1 of 2 12 LastLast

Posting Permissions

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