Results 1 to 6 of 6
  1. #1
    romanomad is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3

    Print print current record event procedure not working

    Hello,

    I want to print selected record in report view from a form. I found the visual basic code to limit my report to the current record using a form button but nothing happens!! At first it worked but I had to enter in the correct "ApplicantID", now nothing happens. I have started over from scratch several times and now I cant get event procedures to work at all.

    My report is called "rtpAdvisingForm" and my unique identifier is the "ApplicantID" from the Applicant table, which is what my form and report both pull from. Macros are enabled and location is trusted.



    Here is the code I am using:

    Private Sub Command149_Click()
    Dim strReportName As String
    Dim strCriteria As String
    strReportName = "rptAdvisingForm"
    strCriteria = "ApplicantID='" & Me!ApplicantID & "'"
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
    End Sub

    What is going on?! Is there an easier way to get around this with macros?

    I attached my database

    thanks!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try changing the strCriteria to:

    strCriteria = "[ApplicantID]= Forms!rptAdvisingForm!ApplicantID"

    Alan

  3. #3
    romanomad is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3
    my form is called "Applicants", "rptAdvisingForm" is actually my report. I tried this anyway and again, nothing happens.

    Here is the code now:

    Private Sub Command149_Click()

    Dim strReportName As String
    Dim strCriteria As String

    strReportName = "rptAdvisingForm"
    strCriteria = "[ApplicantID]= Forms!Applicants![ApplicantID]"
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


    End Sub

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is ApplicantID a String or Numeric DataType?

  5. #5
    romanomad is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3
    "ApplicantID" is the name of the field with the unique identifier that I am using to find the current record. It is autonumber.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Just change
    strCriteria = "ApplicantID='" & Me!ApplicantID & "'"
    ...to...
    strCriteria = "ApplicantID=" & Me!ApplicantID
    ...and eliminate the quotes.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print Report from Current Record
    By hnkford in forum Reports
    Replies: 15
    Last Post: 05-22-2015, 08:08 AM
  2. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  3. Replies: 1
    Last Post: 02-18-2010, 01:02 PM
  4. Print Preview different from Print Hardcopy
    By peterc in forum Reports
    Replies: 4
    Last Post: 10-27-2009, 05:35 AM
  5. Replies: 1
    Last Post: 11-29-2005, 08:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums