Results 1 to 13 of 13
  1. #1
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64

    SubQuery not recognizing criteria reference to a cell on a form

    I'm trying to run a query on the click of a button. The query is dependent on a couple subqueries. Two of the subqueries have one criteria, which is in a cell on an open form. [Forms]![Project_Info].[ID]
    If the form is open, I can run the subqueries individually and they recognize the data reference just fine, but if I try to run the main query, when it calls the subquery (it seems), I get a "Microsoft Access database engine does not recognize '[Forms]![Project_Info].[ID]' as a valid field name or expression." Am I missing something here?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The Project_Info form is still open, right?

  3. #3
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Yes. I've kept it open during each test

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The syntax looks right and should work.

  5. #5
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    Yes... It's vexing me.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can't replicate issue. Do you want to provide db for analysis? Follow instructions at bottom of my post.
    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.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    When something that should work doesn't, I start looking for corruption. Try *importing* your db into a new fresh db and see if the issue follows. http://www.btabdevelopment.com/ts/impnew

  8. #8
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    OK, so I've narrowed it down a little bit. Part of the problem seems to be that one of my subqueries is a crosstab subquery. It seems whether I try to apply the criteria to the subquery of the crosstab query or to the query that joins the cross tab query to another, I get this error message. I really need to be able to filter the subquery of the crosstab query by this criteria otherwise, I get a ton of extraneous data.

    I'm reluctant to send the db, June, because it's huge. It would be quite a task to separate this component from it.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It is pretty easy to limit what is in your db by importing into a new db and only selecting what is needed for the import.

  10. #10
    Historypaul is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    64
    OK... I've been researching and it looks like the problem is simply that I can't run a crosstab query on a subquery that has filter criteria that it has to look up. Apparently, the crosstab query doesn't know how many columns it will have to have if I'm trying to filter its subquery with a reference. What I did was make the subquery of the crosstab query a "make table" query. I run the make table query with a vba command, then run the main query, which runs the crosstab query off of the new table and combines it with the data from another table and voila... it works. It seems to run pretty efficiently, too, since all of my data handling is still being handled by queries.

    My only fear is that eventually, I'm splitting this thing up and running the back end on a SQL server. I hope this doesn't screw that up.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Thanks for the update.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't have much occasion to use crosstab but I have read they deal with dynamic parameters differently. See if this helps http://allenbrowne.com/ser-67.html
    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.

  13. #13
    onechriswhite is offline Novice
    Windows Vista Access 2002 (version 10.0)
    Join Date
    Jul 2010
    Posts
    22
    I had the same problem. Converted to MakeTable - Joy! Now also I can use the same crosstab query for all sorts of different filters, just re-populate the table accordingly. It's genius. Thanks.

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

Similar Threads

  1. Referring to a cell with a date in query criteria
    By Historypaul in forum Queries
    Replies: 5
    Last Post: 06-08-2014, 03:54 PM
  2. Replies: 8
    Last Post: 10-24-2012, 12:47 PM
  3. Database Recognizing VBA Change to Form
    By orcinus in forum Programming
    Replies: 2
    Last Post: 10-28-2011, 01:18 PM
  4. Replies: 1
    Last Post: 05-18-2011, 12:23 PM
  5. Can we post Access cell data to Excel cell properties?
    By Zethro in forum Import/Export Data
    Replies: 1
    Last Post: 12-13-2005, 08:42 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