Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Not able to insert data - access - sql - vba

Posted on 2014-04-28
4
Medium Priority
?
585 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 40

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 40

Accepted Solution

by:
PatHartman earned 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

886 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