Consulting

Results 1 to 7 of 7

Thread: Solved: print current record

  1. #1
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    Solved: print current record

    when I set up a button to print the current record, it prints the form also. If I set up a report, It shows me all of the records. How can I print just the current record without the form?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  2. #2
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    3
    Location
    Create a report with the fields you require. Create a query with the fields that will appear in the report. In the criteria for chosen field enter a parameter e.g.[Enter a date]

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    good lead

    Hey Tanis,
    Thanks for the help.
    I have the report and the query. In the criteria for the query it now asks for the name.(when I run the query)

    [Enter RecipeName]

    hope I am following you on this. The problem is it just brings up the table with only the record I typed in the box. I have been reading and I thought this should be easy but.....could use another lead if you see something I am doing wrong.

    Steve
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    Hi Lucas,

    I remembered seeing an answer to this on another web site and I just found it. This site seems to be a pretty nice one too and they are very open to us using they're code. This is the link to the page where the code is.

    Gary B
    www.mvps.org/access/reports/rpt0002.htm

  5. #5
    VBAX Newbie
    Joined
    Feb 2005
    Location
    Devon
    Posts
    5
    Location
    Hi

    Use the Where argument of the Docmd.OpenReport method to filter your report...something like this

    Docmd.OpenReport "MyReportName", acNormal , , "RecipeID = " & Me.RecipeID

    This assumes that you have the RecipeID available as a reference on the form you're clicking the command button and that it's a numeric data type. You don't need any criteria in the query your report is based on, just the fields you want shown on the printed report.

    HTH

    Alan

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    two good solutions!

    Thanks GaryB & AlanG,
    Gary, your link was to a piece of button code that works great, even gives a preview first if you want, or set it to print.

    AlanG, your piece of button code works great too. It just prints it out.

    I learned a lot on this little excursion. appreciate the insights.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Marking it solved, Steve?
    (Hint: Click the Thread Tools link at the top of the page.)
    ~Anne Troy

Posting Permissions

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