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 
Execute insert vba syntax
Rex Williams 
   
4 years ago
Books Table with 5 fields: 1 is autonumber, 3 text fields 1 number field
fields autonumber,Title, First, Last, AuthorID

My form has txtboxes with data
txtTitle,txtlast,txtfirst,txtAuthorID

this works to insert a record with any of the fields if only one field is used.  

db.Execute "INSERT INTO Books (txtFirst) VALUES ('Rex');"

  ' this adds a record with Rex in the First field.

db.Execute "INSERT INTO Books (txtAuthorId) VALUES (55);"  '  adds a record with 55 in AuthorId field

I can't do this
db.Execute "INSERT INTO Books (Title) VALUES (txtTitle,txtLast);"  

what is the syntex to Execute "insert   txttitle,TxtLast,TxtFirst,TxtAuthorId into table books?

Thanks for any help I'm just a 78 year old retired guy that likes databases.
Kevin Robertson  @Reply  
           
4 years ago
Hi Rex,

Remember you need quotes around your text fields.

CurrentDb.Execute "INSERT INTO Books (Title, First, Last, AuthorID) " & _
   "VALUES (""" & txtTitle & """, """ & txtFirst & """, """ & txtLast & """," & txtAuthorID & ")"
Kevin Robertson  @Reply  
           
4 years ago
I recommend the SQL Seminars.
Part 2 covers Action Queries (and more) including INSERT INTO.
Rex Williams OP  @Reply  
   
4 years ago
Thanks and thanks again!  I don't understand all the punctuation.  When to use single double or doubledouble but I can learn.
The  whole statement I need to understand. I was having the same trouble trying to make a dim sql and using the docmd runsql
Thanks again from a old man.

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: 5/7/2026 2:01:20 PM. PLT: 1s