Results 1 to 12 of 12
  1. #1
    bubai is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162

    Can't work on formula field query.

    I am trying to make a query using fields from multiple tables. I used the Expression builder to create it and it is a formula field where multiple table fields are involved. But whenever i run the query Access asks for a parameter value in a modal dialogue for the value of the fields. Is it because the field names has Square brackets around it? But access puts that automatically. How to make it work properly?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Brackets are fine. Somewhere, is a field not spelled correctly,
    or
    since you have many tables that may have the exact field name, you must differentiate them by putting the table name AND field... myTable.EmpID

  3. #3
    bubai is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Table references came automatically as Expression builder was used. The query involves [Item!] table and a query [PI4MatArrived]. Both of them has a common field [PI #]. So i took [Material] and [PI #] field of Item table in the query builder and under [PI #] i put a criteria "=[PI4MatArrived]![PI #]" as i want only those Materials whose corresponding PI # matches with the query PI #. But as i run, it asks for [PI4MatArrived]![PI #] value in the modal dialogue box.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    use a DOT like my example.

    [PI4MatArrived].[PI #]

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Post the SQL of your query.

    Shouldn't use punctuation, special characters (exception is the underscore) or spaces in object names.
    A better name for [PI #] would be [PINum] or [PI_Num].

  6. #6
    bubai is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Dot is not working. Still says "Enter parameter value." SQL is:
    Code:
    SELECT Item.Material, Item.Qty, Item.[PI #]
    FROM Item
    WHERE (((Item.[PI #])=[PI4MatArrived]![PI #]));

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I am trying to make a query using fields from multiple tables
    You don't have the table "PI4MatArrived" in the query record source.

    I would expect the base query to look like: (AIR CODE!!)
    Code:
    SELECT Item.Material, Item.Qty, Item.[PI #]
    FROM Item INNER JOIN PI4MatArrived ON Item.[PI #] = [PI4MatArrived].[PI #]
    or
    Code:
    SELECT Item.Material, Item.Qty, Item.[PI #]
    FROM Item INNER JOIN PI4MatArrived ON Item.[PI #] = [PI4MatArrived].[PI #]
    WHERE [PI4MatArrived].[PI #] = [Forms]![YourFormName].[YourControlName];
    How are the two tables related?
    One to many relationship? Which table is the "one" table?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    What is PI4MatArrived? If it is a table - must be included in the FROM clause. And really should have a JOIN clause that links tables on PK/FK fields then the WHERE criteria probably not needed.
    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.

  9. #9
    bubai is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    Sorry, there is a correction. "PI4MatArrived" is a query from where i get the [PI #]. Thus there is only one table and one query and they don't have any relation.The first code worked fine.
    However it seems to work as well if i bring the query "PI4MatArrived" to the query builder (previously i was making the query with only Item table). In that case the SQL is:
    Code:
    SELECT Item.Material, Item.Qty
    FROM Item, PI4MatArrived
    WHERE (((Item.[PI #])=[PI4MatArrived]![PI #]));
    Thanks guys! I was really stuck.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Both datasets have [PI #] - they can be joined in query.
    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.

  11. #11
    bubai is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    162
    What is the advantage of joining them when they are working without any join?

  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,626
    Supposed to be better performance, especially with large datasets. But if it is working satisfactorily with the WHERE clause, then good.
    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. Calculating a new field using a formula
    By mccambe21 in forum Queries
    Replies: 1
    Last Post: 09-04-2013, 12:16 PM
  2. formula refer to header field
    By poire in forum Database Design
    Replies: 3
    Last Post: 06-02-2012, 08:22 PM
  3. Formula field
    By vidplaylist in forum Access
    Replies: 1
    Last Post: 12-07-2011, 04:37 PM
  4. Formula field
    By vidplaylist in forum Queries
    Replies: 3
    Last Post: 12-06-2011, 03:45 PM
  5. Field in query formula question
    By jcaptchaos2 in forum Access
    Replies: 7
    Last Post: 04-24-2011, 06:32 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