Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Thanked 0 Times in 0 Posts

    Insert into? (Access 2000)

    How can i create an Insert into command, to insert all the values from the one field to all the corresponding valuse for the
    same product in the other field? In a table called vegetables i have two fields. The first is called north and the second south.The table is called Products.
    The first field in the table is called productID and is an Auto number. I want to insert all the values ( liters) from the field south into the field north.
    I will be very grateful if someone help me construct the comman with visual basic.

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Frederick, Maryland, USA
    Thanked 2 Times in 2 Posts

    Re: Insert into? (Access 2000)

    Below is one example of your insert statement:

    Dim strSql as string
    Dim N as string
    N = XYZ 'Condition to get data from query

    strSql = "INSERT INTO Table1 (Fieldname1, Fieldname2)"_
    & " Select field1, field2"_
    & " From Table2"_
    & "Where ([field1]= ('" & N & "'));"

    Set the where clause to what you need it to evaluate to.

    I don't exactly understand your description of what you are trying to do but the above syntax should set you in the right direction.
    - Is the table Products a second table?
    - Is North and South in the same table and you are tying to update the liter values from south to north. If so, what does the table Products have to do with this?
    - If there are two tables, you will need to join on a common field. What is this field?

    (It's been a while!)

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Mt Macedon, Victoria, Australia
    Thanked 45 Times in 44 Posts

    Re: Insert into? (Access 2000)

    You can use the query grid to build a query without having to write an sql statement.
    Start a new query, then convert the query into an update query (go to query in the menus) or append query.
    It is not clear to me whether you want to add new records to a table (append query), and put values into existing records (update query).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts