Results 1 to 5 of 5
  1. #1
    bv21 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2

    link to a separate report from a report

    I have a field in a report (call it FIELD1) that I have created a macro for - the macro generates a new report with all the records that contain the answer for FIELD1 - I would like to be able to click on this field and have the report generate based on what is in that field currently - but when I click on the field it pulls up an [lookup field1] box and I have to make sure I type in exactly what I need - is there anyway to have that lookup linked to a table of the specific records I want to search by? or even better if it was able to understand the entry that was in FIELD1 that was just clicked on return those records in the linked report? your help is greatly appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Is this what you're trying to do?

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bv21 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    2
    thanks - i'll try that - is there anyway to have: DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"

    where "FieldName = '" will pull whatever is in that field? or will I have to specify prior, what that fieldname needs to be - thanks!

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    The wherecondition parameter has to resolve at execution time to a string that is a valid limitation on the query that underlies the form. As long as whatever you code fits that description, then you're good. For instance, if you had two control on the form that the VBA was behind, and Control1 had a value of "FirstName" and Control2 had a value of "George", then a parameter
    Code:
     "( " & Me.Control1 & " = '" & Me.Control2 & "')"
    would resolve to
    Code:
    "( Firstname = 'George')"
    which would be a valid limit if there was a field Firstname in the query for the form.

    I've forgotten whether you get nothing or everything if the filter is not valid - I think everything.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Well, typically you know the field name (the code is run from that field after all), and you get the value from the form/report. If you really mean you get the field name too, it can be done.

    Me.ControlWithField & " = " & Me.ControlWithValue

    type of thing
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 29
    Last Post: 12-17-2014, 08:46 PM
  2. Replies: 5
    Last Post: 03-30-2013, 12:56 PM
  3. Combining separate excel report data
    By mikebravo in forum Import/Export Data
    Replies: 7
    Last Post: 04-16-2012, 01:16 PM
  4. Replies: 6
    Last Post: 02-06-2012, 03:53 PM
  5. run a report from 2 separate tables
    By Kajinga in forum Reports
    Replies: 2
    Last Post: 11-23-2011, 05:08 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
  •  
Other Forums: Microsoft Office Forums