Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    103

    Unanswered: syntax for writing to table from vba

    What is the correct syntax for opening a table and writing to various fields within vba (an event from a form)? I want to do this because I have to calculate some of the data at the time of the event, but it becomes static from that point on.

  2. #2
    Join Date
    Apr 2003
    Location
    Homer, Alaska
    Posts
    15
    One of the ways is:

    If you're updating a record that already exists:

    DoCmd.RunSQL "UPDATE tblTable SET Field1=Value1, Field2=Value2 WHERE Field3=Value3"

    If you're creating a new record:

    DoCmd.RunSQL "INSERT INTO tblTable (Field1, Field2, Field3) VALUES (Value1, Value2 ,Value3)"

  3. #3
    Join Date
    Oct 2003
    Posts
    103
    Originally posted by tsulczynski
    One of the ways is:

    If you're updating a record that already exists:

    DoCmd.RunSQL "UPDATE tblTable SET Field1=Value1, Field2=Value2 WHERE Field3=Value3"

    If you're creating a new record:

    DoCmd.RunSQL "INSERT INTO tblTable (Field1, Field2, Field3) VALUES (Value1, Value2 ,Value3)"
    Thank you, I will try that!

Posting Permissions

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