Results 1 to 9 of 9
  1. #1
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    91

    using select query to add records

    Hello Chaps- would someone please explain something to me
    I am new at this and am going through queries.
    i am learning about SELECT queries and INSERT queries.
    My understanding is that a select query will allow one to find (select) a particular record
    and an insert query will allow one to add a new record.
    But my tutorial seems to use the select query to add records??
    If this is correct then what is the point of having an insert query.?


    regards fred

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    A select query will not add records to the underlying table. You might be able to add a record manually through a select query, but that would be no different than adding a record manually to the table. As developers most of us never let users into tables or queries, only forms and reports.

    For clarity, either type of query can return/add multiple records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    INSERT INTO Customers (CustomerName, Country) SELECT SupplierName, Country FROM Suppliers;
    Means find supplier Name and country from the table suppliers

    then Insert them into the table Customers in the fields CustomerName and Country)

    Hope this helps

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Quote Originally Posted by andy49 View Post
    Code:
    INSERT INTO Customers (CustomerName, Country) SELECT SupplierName, Country FROM Suppliers;
    And in case this is the source of your confusion, that's not a select query adding records, that's an insert query that has a select clause in it. There are two syntax options with append (insert) queries:

    inserts a single record
    INSERT INTO...
    VALUES(...)

    inserts any number of records:
    INSERT INTO...
    SELECT...
    FROM...
    WHERE... (optional)

    The second, while it contains a SELECT clause, is still an append query, not a select query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    91
    thanks chaps= it has cleared up the mud a bit
    so if I open a table using a select query and while the form is open I make changes to a record
    on the form -those changes will be made to the underlying table??
    In that case how does one make the query "read only" or rather disallow the operator from
    making changes?
    thanks again

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Most of us developers never let users directly into tables or queries. You control what they can do in forms/reports. A form is easy to make read only. You have much less control over formatting, security, etc with tables/queries.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    A little less technical perhaps, and maybe a good primer for the other link - several types covered

    https://support.office.com/en-us/art...3-5760249fb65c

    Or research it as there's a lot to know about queries in general.

  9. #9
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    91
    thanks for the tips- I will try them now that I am online again
    best regards

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

Similar Threads

  1. Replies: 37
    Last Post: 03-10-2017, 04:57 AM
  2. Query to Select Records and Alphabetize them
    By MarcieFess in forum Queries
    Replies: 2
    Last Post: 10-24-2013, 09:34 AM
  3. SELECT TOP 10 Query returns 12 records
    By Paul H in forum Queries
    Replies: 8
    Last Post: 09-11-2013, 03:38 PM
  4. Delete and/or Select Distinct records query
    By admessing in forum Queries
    Replies: 39
    Last Post: 02-14-2012, 03:50 PM
  5. Replies: 3
    Last Post: 01-04-2011, 07:06 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