Results 1 to 8 of 8
  1. #1
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65

    Query between 2 fields in a table

    Im trying to figure out how to return values in a query when the criteria looks at a table between 2 fields like Between [TBLBuildingLocations]![IBST1] And [TBLBuildingLocations]![IBST2] but im getting an error. any ideas??

  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,928
    What is the error?

    Post the entire sql statement.
    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
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    Well its not and error its like it cannot reconize that table field combo.Click image for larger version. 

Name:	Capture1.PNG 
Views:	15 
Size:	33.5 KB 
ID:	14656

    SELECT TBLAgedLPN.LOCN, TBLAgedLPN.AGE, TBLAgedLPN.LPN, TBLAgedLPN.ASN, TBLAgedLPN.[DOLLAR VALUE], TBLAgedLPN.[VENDOR NAME], TBLAgedLPN.[LAST TRANSACTION]
    FROM TBLAgedLPN
    WHERE (((TBLAgedLPN.LOCN) Between [TBLBuildingLocations]![IBST1] And [TBLBuildingLocations]![IBST2])) OR (((([TBLAgedLPN].[AGE]) Like "Lost") Like "DM 001"))
    ORDER BY TBLAgedLPN.LOCN, TBLAgedLPN.ASN;

  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,928
    Can't reference another table that way. TBLBuildingLocations is not included in the query.

    Do TBLBuildingLocations and TBLAgedLPN have a relationship?
    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.

  5. #5
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    No they don't. What I'm trying is say you have a form it has 2 fields the 1st field has 1 the 2nd has 100. In the query I'm using the criteria section to return all values that are between 1 and 100 looking at this form. This works but I'm trying to do the same thing with a table. In my case IBST1 has a value of 1 and IBST2 has the value of 100 this doesn't work. I would just use the form since I know it works but I can't open the form every time and it only works if the form is open.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    That really makes no sense. Entering criteria into controls of a form and referencing those controls in query as dynamic parameters is not the same as referencing the entire field of a table.

    These tables must have some kind of association. Need to know more about data structure.
    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
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    So is it possible to reference the form when the form is closed?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    No, it is not.
    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. Query Where Two Fields from a Table Are Linked
    By racefan91 in forum Queries
    Replies: 7
    Last Post: 10-04-2013, 01:37 PM
  2. Replies: 0
    Last Post: 08-20-2013, 07:40 AM
  3. Replies: 11
    Last Post: 09-15-2011, 03:52 PM
  4. Replies: 3
    Last Post: 08-16-2011, 02:20 PM
  5. Replies: 3
    Last Post: 08-25-2010, 07: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