Results 1 to 4 of 4

Thread: Append query.

  1. #1
    Join Date
    Feb 2004
    Posts
    47

    Unanswered: Append query.

    Hi,

    I have a form with a textbox (txtAddName).

    I would like to append the value of this txtInput to a table (TblName) with the following structure:

    NameID
    Name
    Address

    Could someone help me out with the code for this? Can this be done with an Append query?

    Rgds,

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Why don't you bound the Form to the table?

  3. #3
    Join Date
    Feb 2004
    Posts
    47

    From form to append query

    Hi Hamm,

    The form is a transaction form that links to multiple tables. Hence I cannot bind it to a table.

    My issue was with Append query. I could not build an Append query without a table in QBE (as the input was coming from a form). I found the way out. For the benefit of those who see, here it is...

    The SQL query, I typed in was:

    INSERT INTO TblName (Name, Address) VALUES (txtAddName, txtAddress).

    Access turned this into:
    INSERT INTO TblName ( Name, Address ) SELECT txtAddName AS A, txtAddress AS B;

    It works well in QBE. Codewise it works with:
    docmd.runSQL "INSERT INTO blah blah;"

    However it doesn't work with:
    currentdb.execute "INSERT INTO the same blah blah;"
    This gives an error:
    "Too few parameters. Expected 2".

    I prefer currentdb.execute as it avoids all the warnings.

    Any help is appreciated.

    Rgds,

  4. #4
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: From form to append query

    I had the same problem. And I use DoCmd. You can avoid the warnings by means of DoCmd.setWarnings False before the runSQL
    After that you can activate the warnings with DoCmd.setWarnings True

Posting Permissions

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