Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Append Query
Mara Lucic 
    
2 years ago
Hi, I am building a rental inventory database. I created an inventory table and history table where any past orders are being stored in. I have created a Create New Order form with continuous sub form that is supposed to show items picked from the inventory and added to that order. I have created a button Add Items to order that opens a search inventory form in new window with button next to each item Add to Order. Button has append query that just doesn't work for me. I am getting a warning message of number of different violations. In addition to that warning message is referring to number of records that were not added due to violations (total number of all of the inventory items) even though button is supposed to add just that one inventory record I click on to add, it is not supposed to add entire inventory.  

I guess my question is how to create a append query button to add one record to new history table tagged with specific order number and display it in continuous sub form.

Thank you
Mara Lucic OP  @Reply  
    
2 years ago

Mara Lucic OP  @Reply  
    
2 years ago

Jennifer Neighbors  @Reply  
     
2 years ago
What does your append query currently look like? Would you please post a screenshot?
Mara Lucic OP  @Reply  
    
2 years ago

Jennifer Neighbors  @Reply  
     
2 years ago
Hi, Mara. I'm sorry, but I'm not the best person to help you with this because I use VBA "INSERT INTO" statements for my append queries. I'm confident another person could mentor you better after viewing this image. Thanks for posting it!
Kevin Yip  @Reply  
     
2 years ago
Your query adds the *entire* InventoryT table to your destination table, and that's why you get those errors.  To add just one record, it has to be done completely differently.  See the picture below.  First, you do not put InventoryT there.  That area should be BLANK, because you are *not* appending from InventoryT.  You are appending from the values on your form (am I right?).  So you need to put the *values* (not fields) in the query designer, as shown in the picture below.  The only table that needs to be in the query is the destination table as shown in the pic, which you specify when you click the "Append" button on the ribbon.
Kevin Yip  @Reply  
     
2 years ago

Mara Lucic OP  @Reply  
    
2 years ago
thanks, i think i get what you are saying, makes sense. I am new to access so a bit overwhelmed. When you say "value" what do you mean by that in respect to my form?
Kevin Yip  @Reply  
     
2 years ago
You need to bring your form's values to your query, so that your query actually references the *literal* values that you want to append, not field names.  If your user enters 100 and 200 into the fields, then you literally have to put these values into your append query, so it will look something like:

   INSERT INTO MyTable SELECT 100 AS Field1, 200 AS Field2, ...

That is usually done with VBA, by creating an SQL statement directly as Jennifer alluded to above (without using the graphical query designer).  You put the form's values into the SQL statement with a VBA technique called string concatenation.  The resulting VBA code may look like:

     sql = "INSERT INTO MyTable SELECT " & [Put your form field 1 value here] & " AS Field1, " & [Put your form field 2 value here] & " AS Field2, ..."

All this encompasses many topics so you need to take Richard's lessons to get all the info.
Mara Lucic OP  @Reply  
    
2 years ago
Thanks, that helped. I did everything as instructed, however i am receiving message "Compile Error: Expected Expression". Seems like spelling mistake, but i checked everything numerous times and i can;t figure out what is the issue.

Here is my code:

Private Sub AddToOrderBtn_Click()

Dim S As String

S = "INSERT INTO OrderDetailT (OrderDetailID, OrderID, InventroryID, MTR, Serial#, Category, Class, Size, Type, Heat#, Description, Price, RentalStart, RentalEnd, PSID, RSID )" & _
"SELECT " & OrderDetailID & ", " & OrderID & ", " & InventoryID & ", " & MTR & ", " & Serial# & ", " & Category & ", " & Class & ", " & Size & ", " & Type & ", " & Heat# & ", " & Description & ", " & Price & ", " & RentalStart & ", " & RentalEnd & ", " & PSID & ", " & RSID & ";"

DoCmd.RunSQL S
InventoryPickF.Form.Requery

What am I missing?

Thanks again!
Mara Lucic OP  @Reply  
    
2 years ago
I have put Type in parenthesis [Type] and that seemed to fix that error but now i am getting new error 3134

Mara Lucic OP  @Reply  
    
2 years ago

Adam Schwanz  @Reply  
           
2 years ago
Are all of those numbers? I don't use docmd.runsql so I'm not sure if it's different, but with a currentdb.execute SQL statement you would have to quote double double quotes for strings. Are RentalStart/End date/time fields? You would need to use # around them. I would also put Heat# in brackets as well regardless as special characters can cause anything to happen.
Richard Rost  @Reply  
          
2 years ago
Start with one field at a time, and add fields until you figure out which one is causing the problem.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/14/2026 1:32:21 AM. PLT: 0s