Solved

Not able to insert data - access - sql - vba

Posted on 2014-04-28
4
577 Views
Last Modified: 2014-04-28
Hi Experts,
I am not able to run the insert query because of some errors, Here I am attaching the db with the table and and the query, Please kindly help,
Thanks
test.accdb
0
Comment
Question by:gtmathewDallas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 40027480
Please tell us what the errors are.  Not everyone can download your database.
0
 

Author Comment

by:gtmathewDallas
ID: 40027515
While I am running the insert query through vba, its not appending to the table and shows no errors, so i tested it directly with the query (which got from immediate window) I am getting a big message including the errors type conversion violation - key violation - lock violation - validation rule violation etc. I checked the properties of each fields, but it seems ok there.
0
 
LVL 36

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40027662
The problem is that the primary key field is not being filled.  Either change it to be an autonumber so it will automatically generate a new number for each insert or add the ID field to your append query.

Comments -
Access generates "ID" as the PK name because it can't possibly guess at a meaningful name.  You should change it yourself.  for this table, InventoryID would be a good choice.

I would suggest filling "empty" fields with null rather than zero length strings.  It can be problematic to allow both therefore, I always set the AllowZeroLengthStrings property to no to avoid the problem.  Either a field has a value or it is Null.  ZLS just adds one more thing you need to test for in your queries.

Dates are delimited by # NOT '.
0
 

Author Comment

by:gtmathewDallas
ID: 40027695
Thanks a lot PatHartman, sorry to miss that, I created a new Id field and set that to auto number as you said, Its working fine now,
Thanks again
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question