Results 1 to 3 of 3
  1. #1
    elysia is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2018
    Posts
    1

    Exclamation Syntax for this Query


    Hey! So I'm having a bit of trouble writing this syntactically and hopefully the explanation of my situation below is not too confusing.

    Specifically, I have three tables (1, 2, 3) and there are three different fields (A, B, C) within Table1 I want to reproduce and two different fields (X, Y) to map them with. Basically, Table 1 should be updated in columns 1, 2, 3 based off 2 and 3.


    It should be mapped to check case one first and then case two only if case one didn't yield a join:


    Case1:


    Field A - all cells from A should be replaced by those from another field in table2 where for that row table1.fieldx=table2.fieldx


    Field B - all cells from B should be replaced by those from another field in table3 where for that row table1.fieldx=table3.fieldx


    Field C - all cells from C should be replaced by those from another field in table2 where for that row table1.fieldx=table2.fieldx


    Case2:


    Field A - all remaining cells from A should be replaced by those from another field in table1 where for that row table1.fieldy=table2.fieldy


    Field B - all remaining cells from B should be replaced by those from another field in table3 where for that row table1.fieldx=table2.fieldx


    Field C - all remaining cells from C should be replaced by those from another field in table3 where for that row table1.fieldx=table3.fieldx


    So logically, I was thinking of doing a select join first to create two separate tables for each case then somehow merge to two (maybe update tblCase1 by checking for null cells) but I'm kind of lost in putting it together in code. I've googled, watched videos, played around with the language. I just can't get the syntax right.

    Would really appreciate some help on this.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you dont need code.
    have you tried building the queries in query design? Start with SELECT queries to see if it pulls the correct data.
    if so, change it to UPDATE query.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Agree with ranman about using update queries
    However, if this a process you will need to repeat, I would save the queries as SQL and add them to a VBA procedure to run in sequence
    BTW - Access doesn't have cells - it has fields and records
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Guide for interpreting MSDN / MS documentation syntax-syntax !!
    By pisorsisaac@gmail.com in forum Access
    Replies: 4
    Last Post: 11-18-2017, 07:07 AM
  2. Convert SQL Server Syntax To Access Query Syntax
    By chalupabatman in forum Queries
    Replies: 1
    Last Post: 10-18-2017, 08:53 PM
  3. query syntax
    By ivor in forum Queries
    Replies: 9
    Last Post: 06-13-2013, 02:12 AM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 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