Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2024
    Posts
    8

    Question How do i reference fields from a query with two tables and field names are the same?

    Objective: Using the Prod file as the master to match to the BOB file. Then because there are duplicates, update with an update sql call, update the BOBTest.[Volume & page #] field to make it unique from other records in the table. Having trouble accessing the fields after the query. Query works fine but i can't access the fields.



    Have tried numerous solutions to no avail. I am really stuck. Please help!!
    For example;

    RS!Fields([BOBTest].[Volume & page #]) Tried varies "Field" connotations.
    RS.([BOBTest].[Volume & page #])
    RS.[BOBTest].[Volume & page #]
    RS.[Volume & page #]

    Searched a lot but no satisfactory answer. Maybe querydef but i don't understand how to use it. I need clear example accessing the fields.

    Please help!!

    / Code
    Select statement:
    QRS = "SELECT [Prod File].[Volume & page #], BOBTest.[Volume & page #]
    FROM [Prod File], BOBTest
    WHERE ((([Prod File].[Abstract Bk # & Pg])=BOBTest.[Abstract Bk # & Pg]) And (([Prod File].[Volume & page #])=BOBTest.[Volume & page #]));

    Set RS = db.OpenRecordset(QRS, dbOpenDynaset, dbPessimistic)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Could use alias names in query and refer to those with VBA then the table qualifiers would not be an issue.

    Really should not use spaces nor punctuation/special characters in naming convention nor exact same field name in multiple tables.

    Without spaces and special characters, brackets are not needed.
    RS.("tablename.fieldname")
    RS!tablename.fieldname
    works

    Including brackets as following work.
    RS.("[tablename.fieldname]")
    RS![tablename.fieldname]

    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
    Join Date
    Apr 2024
    Posts
    8
    June7, Many thanks for your response!! Modified query using Aliases. Problem solved. Again, many thanks!!

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

Similar Threads

  1. Replies: 6
    Last Post: 02-18-2022, 02:30 AM
  2. Replies: 1
    Last Post: 05-20-2021, 04:27 PM
  3. Replies: 5
    Last Post: 04-03-2021, 04:01 PM
  4. Replies: 13
    Last Post: 08-18-2014, 02:07 PM
  5. Replies: 6
    Last Post: 02-11-2014, 05:20 AM

Tags for this Thread

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