Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding a report (a2002)

    Hi all,

    A friend has sent me a really nice lightweight appointment calender which they found on the net. I thought it would be nice to be able to print out the days appointments if necessary and thought a report would do this for me. I made a new report and added all of the pertinent fields and then added a button to the form using the built in wizard function. I have added some test data which shows on the report but when I click the button nothing appears to happen.

    Am I trying to do the wrong thing in the wrong place? and if I do get it to print like this how would I limit the print to just the day I am viewing?

    Cheers


    Steve

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

    Re: Adding a report (a2002)

    You haven't included enough specific information to get an answer. What does the wizard-built code look like? Do you have the click event of the button connected to the code? Is this appointment calendar and Access form or something else?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a report (a2002)

    My apologies



    The code behind the button is just what the MS wizard adds (during set up it asks where you want to get the information from, in this case repAppointments)

    Private Sub reportprint_Click()
    On Error GoTo Err_reportprint_Click

    Dim stDocName As String

    stDocName = "repAppointments"
    DoCmd.OpenReport stDocName, acNormal

    Exit_reportprint_Click:
    Exit Sub

    Err_reportprint_Click:
    MsgBox Err.Description
    Resume Exit_reportprint_Click

    End Sub

    I just assumed that this would then print the report.

    Thanks


    Steve
    Attached Files Attached Files

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a report (a2002)

    you need to add a filter to the code. That is after the 2 commas after acpreview. I added a filter to show only today's appointments. You could play with it that instead of DATE (which gives today's date) it could be according to the date clicked on the calendar:

    Dim stDocName As String

    stDocName = "tblAppointments"
    DoCmd.OpenReport stDocName, acPreview, , "fldDate= #" & Date & "#"

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a report (a2002)

    I "do not know how this happened, but your code has another issue which is that the report's name is tblappointments not repappointments as you wrote.

  6. #6
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a report (a2002)

    Thanks, I will try that, and I had actually already spotted that wrong name but it didn't make a difference when changed.

    Cheers


    Steve

  7. #7
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a report (a2002)

    Hi,

    Thanks for that but it didn't seem to work as it just displayed the report on screen when the button was 'clicked' however I think I have just learned what acPreview does. I looked behind the wizard button again and changed it to acNormal,, "fldDate=#" & Date & "#" and it does print out the current dates appointments.

    You suggested however that it may be possible to be able to print the record for any day that you were previewing on screen. Any ideas how that might work?

    Cheers

    Steve

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

    Re: Adding a report (a2002)

    If the command button is on the main form, use

    DoCmd.OpenReport "tblAppointments", acViewPreview, , "fldDate = #" & Format(Me.TheDate, "mm/dd/yyyy") & "#"

    If the command button is on the subform, use

    DoCmd.OpenReport "tblAppointments", acViewPreview, , "fldDate = #" & Format(Me.Parent.TheDate, "mm/dd/yyyy") & "#"

    (The Format function is to force the date into US date format, wnatever the user's date setting is.)

  9. #9
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a report (a2002)

    I see Hans got there first. Thanks

Posting Permissions

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