Results 1 to 4 of 4
  1. #1
    chdui is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    2

    OpenReport macro question

    Hi all,



    First time using Access 2013 here.

    I've built an Access Database that captures information about employee ticket quality using one form and drops it into a table (QA Reviews). What I would like to do then is run a report to pull the last 5 entries for a specific employee.

    What I have done is create a Report that has all of the fields I need (QA Review Report) and then have created a second form (Run QA Report) that includes the 'Consultant Name' field and an OK button that will run a macro when pressed.

    What I have so far in the macro code is as follows:
    DoCmd.OpenReport "QA Review Report", acViewReport, "", """Consultant Name="" & [QA Reviews].[Consultant Name]", acNormal

    However, when running this form, it still doesn't produce anything and I also have not figured out how to get it pull the last five entries in the table for that specific 'Consultant Name'.

    Any assistance would be greatly appreciated.

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That is not macro code - it is VBA.

    Too many quote marks. Variables do not go within quote marks. Parameters for text fields need apostrophe delimiters. Field name has space so need [] delimiters. Probably don't need the [QA Reviews] prefix.

    DoCmd.OpenReport "QA Review Report", acViewReport, , "[Consultant Name]='" & Me.[Consultant Name] & "'", acNormal

    Try setting the report RecordSource query with TOP 5 parameter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    chdui is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    2
    Thanks for your reply! Sorry, meant to say that I converted the Macro to VBA in order to view the code better.

    So running into an additional problem...however, the code does work to an extent.

    When I run the form and choose the Consultant's name from the drop down list, the report will open and display the results. What happens, though, is that no matter the name I choose from the drop down menu, the report will just display the selected name (from the 'Run QA Report' form) in the 'Consultant's Name' box. In essence, it is changing the name from my master table that holds all of the information to whatever name I choose when I ask it to run the report. This new name then gets saved in the 'QA Reviews' master table.

    To try and get around this error, I created a query ('QAQuery') that asks for the Consultant's name with [Which consultant?] in the criteria box. While the box pops up prompting for the consultant's name, it again, will take any name and just change the output name to whatever I entered into the query parameter box. I'll note that if I enter a non-existent name in my database, it will produce no results, as it should.

    I feel like I have explained that terribly, but if you're able to offer any assistance, guidance would be appreciated.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Controls used to input filter criteria must be UNBOUND.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. DoCmd.OpenReport Filter Question
    By booismycat in forum Access
    Replies: 5
    Last Post: 06-12-2014, 03:32 PM
  2. Macro question
    By Deb4566 in forum Access
    Replies: 5
    Last Post: 03-14-2013, 06:11 PM
  3. Macro Question Please Help
    By bmschaeffer in forum Access
    Replies: 7
    Last Post: 10-14-2011, 06:20 PM
  4. Replies: 2
    Last Post: 10-13-2011, 09:14 AM
  5. Macro Question
    By Desstro in forum Programming
    Replies: 1
    Last Post: 06-18-2010, 10:05 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