Running an Append Query Usin a form Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CHUBBYCARROL
    New Member
    • Mar 2007
    • 3

    Running an Append Query Usin a form Button

    Hey All,

    A friend of mine told me about this forum, I've been pooling my hair out for the past few nights trying to figure this out =( . I'm a complete "noob" when it comes to ACCESS.

    I'm trying to use Access to create a form that will append new client's data into a table, this table will then be "Mail Merged" to MS Word to print out a letter with rate quotes and such.

    What I have done so FAR:

    1. Created a table in "Tables" called "Customer" (this table has all the needed fields like: First Name, Last Name and so on.)

    2. Created an Append Query in "Queries"

    3. Used the forms wizard to create a form

    4. Added a button "Add Record"

    Now, how do I get that button to run the query to append newly-entered data into the "Customer" Table?

    Big hugs will be provided in exchange for valuable information.

    Thanks,
    CHUBBYCARROL
  • FireMedic
    New Member
    • Mar 2007
    • 17

    #2
    Hi Carol,

    If I understand this right (and my apologies if I don't) why not just set the record source of your form to be your customers table and just add new record to add a new customer. That way you have no need of an append query at all. Again that is if I understand the situation correctly this would be the least complicated method.

    Let me know if I'm out to lunch on this.

    Comment

    • CHUBBYCARROL
      New Member
      • Mar 2007
      • 3

      #3
      TRUE!,

      Thank you, but how how do i get that "add record" button to work? Do i need to create an event?

      Comment

      • Gerhard
        New Member
        • Feb 2007
        • 23

        #4
        Yes, you do need to put some code in the button's On Click event.
        Try this code:

        DoCmd.SetWarnin gs False
        DoCmd.OpenQuery "Query Name"
        DoCmd.SetWarnin gs True

        Comment

        • Gerhard
          New Member
          • Feb 2007
          • 23

          #5
          Ps. You should include DoCmd.SetWarnin gs False and DoCmd.SetWarnin gs True only when you are sure that your Query works fine.

          Comment

          • CHUBBYCARROL
            New Member
            • Mar 2007
            • 3

            #6
            THANK YOU,

            It works now, but it looks like it doesn't add records it replaces them.

            Here is the SQL for my append query:

            INSERT INTO Customer ( ID, [Last Name], [First Name], [Street Address], [City, State], [Zip Code], [Face Ammount1], Term1, Premium1, Insurer1, [Face Ammount2], Term2, Premium2, Insurer2, [Face Ammount3], Term3, Premium3, Insurer3, Rating, Phone1, Phone2, Agent )
            SELECT Customer.ID, Customer.[Last Name], Customer.[First Name], Customer.[Street Address], Customer.[City, State], Customer.[Zip Code], Customer.[Face Ammount1], Customer.Term1, Customer.Premiu m1, Customer.Insure r1, Customer.[Face Ammount2], Customer.Term2, Customer.Premiu m2, Customer.Insure r2, Customer.[Face Ammount3], Customer.Term3, Customer.Premiu m3, Customer.Insure r3, Customer.Rating , Customer.Phone1 , Customer.Phone2 , Customer.Agent
            FROM Customer;

            Is it wrong?

            Or, is there a way to bypass the query and have the form add records directly into the table?

            !CHUBBY

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32645

              #7
              Originally posted by CHUBBYCARROL
              Hey All,

              A friend of mine told me about this forum, I've been pooling my hair out for the past few nights trying to figure this out =( . I'm a complete "noob" when it comes to ACCESS.

              I'm trying to use Access to create a form that will append new client's data into a table, this table will then be "Mail Merged" to MS Word to print out a letter with rate quotes and such.

              What I have done so FAR:

              1. Created a table in "Tables" called "Customer" (this table has all the needed fields like: First Name, Last Name and so on.)

              2. Created an Append Query in "Queries"

              3. Used the forms wizard to create a form

              4. Added a button "Add Record"

              Now, how do I get that button to run the query to append newly-entered data into the "Customer" Table?

              Big hugs will be provided in exchange for valuable information.

              Thanks,
              CHUBBYCARROL
              If you run through the Form Wizard again and create one against the [Customer] table, then it should create a form where data is automatically saved to the table when you move from one record to another (Or choose Save Record from the Record menu). This should be the default situation using the Wizard I would have thought.
              In case I'm not being clear enough, this means you should not have to use an APPEND query (or even any UPDATE queries) to save the data to the table.

              Comment

              Working...