Results 1 to 6 of 6
  1. #1
    hockeyman9474 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Location
    Manalapan, NJ
    Posts
    45

    Docmd.OpenReport with Query Filtering for a specific value

    Simple question, obvious answer that for some reason eludes me:

    I am using the docmd to open a report. The record source for that report is a query that I am looking to filter with a variable that contains user input. So user selects a value from a combobox, value is placed in a variable called RclNbr that is used as such:

    DoCmd.OpenReport "affectedVINSrpt", acViewReport, "affectedVINS", "RCC=" RclNbr

    I can't get the quotes and tics right in the filter to make it work. Suggestions?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    docmd.OpenReport "affectedVINSrpt",acViewPreview , ,"RCC=" RclNbr

  3. #3
    hockeyman9474 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Location
    Manalapan, NJ
    Posts
    45
    Thanks RanMan256. So I overlooked that I am not comparing to the query itself, but the report field, that is pulling from the query. Here's the problem with this code, its expecting something at the end of the statement such as a quotation.

  4. #4
    hockeyman9474 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Location
    Manalapan, NJ
    Posts
    45
    I was thinking an ampersand so code would look like this

    Private Sub Command1_Click()
    RclNbr = Me.Combo4.Value
    DoCmd.OpenReport "affectedVINSrpt", acViewReport, , "RCC=" & RclNbr
    End Sub

  5. #5
    hockeyman9474 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Location
    Manalapan, NJ
    Posts
    45
    Click image for larger version. 

Name:	Access Open Report Issue.jpg 
Views:	10 
Size:	94.1 KB 
ID:	24899so this is what's going. Using the code provided above, ommiting the query name, where RCC field in report equals the variable RclNbr it still prompts for the parameter.

  6. #6
    hockeyman9474 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Location
    Manalapan, NJ
    Posts
    45
    nevermind, set where clause in underlying query as opposed to report

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

Similar Threads

  1. DoCmd.OpenReport Problem
    By lowesthertz in forum Modules
    Replies: 13
    Last Post: 03-17-2015, 01:17 PM
  2. DoCmd.OpenReport Where Argument
    By snipe in forum Programming
    Replies: 2
    Last Post: 04-24-2014, 10:24 AM
  3. DoCmd.OpenReport WHERE condition
    By bidbud68 in forum Programming
    Replies: 16
    Last Post: 10-19-2012, 05:31 AM
  4. Need help w/ docmd.openreport
    By jwill in forum Reports
    Replies: 3
    Last Post: 06-04-2012, 09:49 PM
  5. DoCmd OpenReport ... where condition with a Like
    By Grooz13 in forum Programming
    Replies: 4
    Last Post: 08-31-2010, 09:04 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