Results 1 to 4 of 4
  1. #1
    SpdRacerX is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    40

    Filter Report by Field in Form

    I tried to search for this but I'm just not getting it.



    I want to filter a report depending on a field in a form. The field is text.

    Here's the simplest way I found, but it returned NO values in the report. Am I missing anything?

    Code:
    Private Sub cmdViewReferral_Click()
    DoCmd.OpenReport "Referral Report", acViewPreview, , "[Assigned To] = '" & Me.[Employee Name] & "'"
     
    End Sub
    [Assigned To] is the Field in the Report (which is grouped by)
    [Employee Name] is the Field in the Form

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The syntax looks correct.

    You say [Assigned To] field is text? So it actually holds the employee name and not an employee ID?

    Is [Employee Name] also name of a combobox on form?
    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
    SpdRacerX is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    40
    [Assigned To] is a combobox in a table
    [Employee Name] is a concatenate expression in a query

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    A combobox in table? You mean you have a Lookup set in table? Lookup does not change the value in the field. You see an alias value but the actual value is still what is in the field. So when you refer to that field you are retrieving the actual data, not the alias.

    I NEVER set Lookups in table. As developer, I want to see the real values when I view tables.
    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. Replies: 9
    Last Post: 12-02-2011, 12:51 PM
  2. Form to Filter Report by Week Number
    By jortizz in forum Forms
    Replies: 1
    Last Post: 05-18-2011, 09:30 AM
  3. Replies: 2
    Last Post: 04-12-2011, 08:33 PM
  4. Filter By Form Report (combobox issue)
    By mike.burns7 in forum Reports
    Replies: 1
    Last Post: 06-10-2010, 07:42 PM
  5. filter by form for report
    By stephenaa5 in forum Reports
    Replies: 1
    Last Post: 05-08-2010, 03:14 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