Hi all , i have this two table
Items_main(ID)
Items(Item_id,Cost,Price,Quantity,Factory)
Item_id is FK linked to ID and (Item_id,Factory) is a PK for Items_main
Now i created a form (named item) to insert records in Items and a button for inserting.
Now i know the easiest way is to create a button for insert records instantley by proprieties but i wanted to learn vba
Here's the code of the button (Item, Cost,Price,Quantity,Factory are the name of controls in form):
Private Sub SaveButton_Click()
Dim second As String
second = "INSERT INTO Items VALUES Item.Value,cost.value,price.value,quantity.value,factory.value);"
DoCmd.RunSQL (second)
End Sub
Now two question:
1)Is there a way not to show the message if i'm sure to insert record after i click button?
2)It insert the item in Items table but it tells me after i inserted the record that there a probems with duplicate PK values, like it was inserted an already existent ID in table Items_main but no query refers to that table
Anyone has any idea? Thanks