Solved

Not able to insert data - access - sql - vba

Posted on 2014-04-28
4
569 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 34

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 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now