Results 1 to 4 of 4

Thread: Insert into statement

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Unhappy

    Hi,

    I want to do something very simple, but cannot get it working.

    I have an MS Access database "Contacs", Table "Friends" with fields "Name" and "surname" and a form with textboxes "txtname" and "txtsurname" and an update command button.

    All I want to do is add names and surnames entered into the textboxes into the table (friends) when the user click the update button ie.

    insert into friends values (txtname.text,txtsurname.text).

    Why does this not work???? It works fine when I hardcode the fields ie.
    insert into friends values ("Dan","Abercrombie").






  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Your variables need to be wrapped in quotes, Give this a shot:

    sSQL = "insert into friends values ('" & txtname.text & "','" & txtsurname.text & "')"


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Talking

    Thank you very much!!! You wont believe this, but I could not find any help in any of my books (teach yourself by Sams) on this problem I had.


  4. #4
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Lightbulb

    Can you explain your problems more specifically? does your program have database object in the form? Maybe the problem your having is due to the unlinked text boxes. For your text boxes properties, you might want to declare datasource and datamember. then for command click botton, just write:
    datMydatabasename.recordset.addnew
    if you have more problems, email me at [email protected]

Posting Permissions

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



Click Here to Expand Forum to Full Width