Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Location
    Moorpark, CA
    Posts
    104

    Smile Unanswered: Adding a record to a Table

    Hi -

    I am trying to write the code that will add a record to a different table if the field of an existing form is updated with a new value. Think of it as a Track Changes program. I am not sure how to go about this, but I know that it can be done.

    Any ideas? suggestions?

    Thanks!

  2. #2
    Join Date
    May 2003
    Posts
    144
    You can add the following script under the AfterUpdate event of that field on the existing form.

    docmd.runsql "INSERT INTO table ......"

    Hope this helps

    SHK

  3. #3
    Join Date
    Nov 2003
    Location
    Moorpark, CA
    Posts
    104

    Question

    SHK -

    It keeps giving me an error that the macro docmd does not exist. Also, does this mean I'd have to have a separate code for each field in a form? Thanks again!

  4. #4
    Join Date
    May 2003
    Posts
    144
    What version of Access do you have?
    If you want to keep track of the changes on each field on the form, then yes, you will need a script for each field. You can have the INSERT INTO statment in a sub and have all the AfterUpdate calls the sub.

    SHK

  5. #5
    Join Date
    Nov 2003
    Location
    Moorpark, CA
    Posts
    104
    Access 2000

  6. #6
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    Quote Originally Posted by Jennay
    Access 2000
    Tried it in the debugging window (CTRL+G)? (entering the DoCmd-statement there i mean?)
    Tried f1 (help) for the DoCmd.RunSQL - syntaxis?

    (I don't have Access 2000 here, else I would have checked it )

  7. #7
    Join Date
    May 2003
    Posts
    144
    Can you post a sample of your program and I will take a look.

    SHK

  8. #8
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    In VBA, click on the Tools Menu, and select References. Scroll down to the Microsoft DAO 3.6 Object Library. If it is not checked, check it. That will ensure you have the proper commands and features available to you.

  9. #9
    Join Date
    Sep 2004
    Location
    Tampa, FL
    Posts
    520
    If it is telling you that theDoCmd Macro does not exist it sounds like you mis-interpreted waht was being said ( I could be wrong though)
    It seems that in the blank beside " After Update" you typed in what SHK said. That will not work.
    to right of the blank click on the box with the three dots, select code builder, then type in the code you want to use.
    Darasen

Posting Permissions

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