Results 1 to 3 of 3

Thread: MS Access, print report button

  1. #1
    Member
    Join Date
    Feb 2006
    Location
    Oxford, UK
    Posts
    123
    Thanks
    1
    Thanked
    0 times in 0 posts

    MS Access, print report button

    Hi guys, I'm quite new to Access, so be gentle!

    I'm currently working with an Access 2000 database (through Access 2003) and I'm trying to make a 'print record' button. I didn't make the database in the first place, so the layout on-screen is hardly as I'd like it, but since its rather a large, business critical database, I'm staying as superficial as I can with the changes.

    So, on the main page you enter a reference number which pulls up the appropriate record from the table. What I'm trying to do is print that record, via a report, so that I can format the report in an easier to read manner.

    I used wizards to create the report itself and a print-report button and pointed it at my new report. Run on its own however, the report produces pages for the entire database. To combat this, I put a WHERE SQL query (which I'm also very new to) in the OpenReport command in the form where the 'print record' button sits. This looks like this:

    DoCmd.OpenReport "Print Report", acNormal, , "[Project Reg Number] = " & Me![Project Reg Number]

    [Project Reg Number] is the name of the field in the table that holds the reference number. It is also the name of the text box that holds the reference number when it sits on the form (the form is usually used to edit the record).

    The problem with this is, when you click on the button, just before it goes to print, it chucks up an 'Enter Parameter Value' dialog box and asks you to enter the reference number again. Except, that the text within the box (above the text-box you enter data into) is the reference number you need!

    So, the SQL query seems to return the reference number, but doesn't put it in the text-box? I'm not sure what's going on, please help!

    Thanks

    Jamie


    PS, that section of code is:

    Private Sub print_report_Click()
    On Error GoTo Err_print_report_Click

    DoCmd.OpenReport "Print Report", acNormal, , "[Project Reg Number] = " & Me![Project Reg Number]

    Exit_print_report_Click:
    Exit Sub

    Err_print_report_Click:
    MsgBox Err.Description
    Resume Exit_print_report_Click

    End Sub

  2. #2
    Does he need a reason? Funkstar's Avatar
    Join Date
    Aug 2005
    Location
    Aberdeen
    Posts
    19,874
    Thanks
    629
    Thanked
    962 times in 813 posts
    • Funkstar's system
      • Motherboard:
      • Gigabyte EG45M-DS2H
      • CPU:
      • Intel Core2Quad Q9550 (2.83GHz)
      • Memory:
      • 8GB OCZ PC2-6400C5 800MHz Quad Channel
      • Storage:
      • 650GB Western Digital Caviar Blue
      • Graphics card(s):
      • 512MB ATI Radeon HD4550
      • PSU:
      • Antec 350W 80+ Efficient PSU
      • Case:
      • Antec NSK1480 Slim Mini Desktop Case
      • Operating System:
      • Vista Ultimate 64bit
      • Monitor(s):
      • Dell 2407 + 2408 monitors
      • Internet:
      • Zen 8mb
    Substitute "Me![Project Reg Number]" with an actual number for now and see if that works.

    You could also try Forms![form name]![Project Reg Number] to see if that helps.

    can't think of anything else to try right now, it's been a while since i had these problems

  3. #3
    Member
    Join Date
    Feb 2006
    Location
    Oxford, UK
    Posts
    123
    Thanks
    1
    Thanked
    0 times in 0 posts

    fantastic

    the Forms![form name]..... solution worked brilliantly, thank you very much!

    Jamie

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. D50 v D70 Buying Advice
    By Syd in forum Consumer Electronics
    Replies: 17
    Last Post: 25-06-2006, 10:00 PM
  2. Belkin F5D6130 802.11b Wireless Access Point
    By Howard in forum Reader Reviews
    Replies: 4
    Last Post: 10-12-2004, 11:20 PM
  3. print sharing probs
    By philip41 in forum Networking and Broadband
    Replies: 4
    Last Post: 01-12-2003, 05:35 PM

Posting Permissions

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