Solved

Not able to insert data - access - sql - vba

Posted on 2014-04-28
4
573 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
  • 2
  • 2
4 Comments
 
LVL 35

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 35

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

832 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