Results 1 to 5 of 5
  1. #1
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45

    Need help with command button to print report of single record

    Okay guys I have this code which will print the report for a single record.



    Private Sub cmdPrint_Click()

    Dim StrCriterion As String

    StrCriterion = "[LotNumber]=" & Me![LotNumber]

    DoCmd.OpenReport "rptWithdrawals", acNormal, , StrCriterion

    End Sub

    Now this code works fine but here is the problem. It is based on one unique identifier for the record (LotNumber). However what happens is that I have two primary keys for this table so using one of the identifier brings me other transactions done for this LotNumber. So I would like it to be able print the one single record by pulling from these two unique identifiers together LotNumber and TransactionDate. Help will be greatly appreciated.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Will the user know the TransactionDate value when the code runs.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45
    Quote Originally Posted by Bob Fitz View Post
    Will the user know the TransactionDate value when the code runs.
    Yes, transactiondate and the lot number need to be input by the user. So the goal is to print that single record.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Try:
    Code:
    StrCriterion = "[LotNumber]=" & Me![LotNumber] & " AND [TransactionDate] = #" & Me.[DateTextBoxName] & "#"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    nightangel73 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    45
    Thank you!!!! It worked!

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

Similar Threads

  1. Replies: 9
    Last Post: 09-17-2013, 11:08 PM
  2. Print report command button
    By Stika in forum Reports
    Replies: 5
    Last Post: 12-21-2012, 05:56 PM
  3. Replies: 3
    Last Post: 09-11-2012, 07:01 AM
  4. Replies: 7
    Last Post: 09-04-2012, 02:51 PM
  5. How to print a single Record's report?
    By yes sir in forum Access
    Replies: 7
    Last Post: 09-20-2010, 07:31 AM

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