Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    108

    Unanswered: saving a record from a form

    Hello, im new here and new to databases (i have basic knowledge)

    ive got a database set up to manage parts for the company i work with, basically it just holds the information (part number ,NSN, name, etc...)

    this is what i need:
    i need to be able to save a record to another table

    ex: i open a form and then click a button and it saves the current record to another table.


    im pretty sure it can be done, but i may be wrong.

    i know no visual basic.
    im experienced with macros/expressions


    if you cant help me could you atleast try to point me in the right direction, or give me some information on another way of doing this.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You need to have an Append Query run from the code behind your command button. Select Make a query in Design You neeed to have an Append Query run from the code behind your command button. After setting up your new table for the records to be added to:

    1) Select "Make a query in Design View" and select the table/query to base it on (the one your original form was based on will do)

    2) Select the various fields you want to append to the new table.

    3) Drop down the Query Menu and select Append Query

    4) Access will ask you for the name of the table to append the data to

    5) On the Query Grid go to a field that is unique to the record (say the Part Number, maybe) and under on the Criteria line for this field enter:

    [Forms]![YourFormName]![YourFieldName]

    This tells Access to append the current record to the new table. Save the Query. Go into Design View for your form and select the command button. Place this code behind your button:

    'This turns off warning about appending record to new table
    DoCmd.SetWarnings False

    'This adds the copy of the record to the new table
    DoCmd.OpenQuery "YourAppendQueryName" 'Adds record to new table

    DoCmd.SetWarnings True 'Turns warnings back on! Remember to do this!

    I think this covers everything, but I don't have a copy of Access at hand, so I may have forgotten a step. If you have any problems come on back! Someone will help!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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