Hi,
Im making a form which allows the user to add products to the database i have created.
Now in my table (tblProduct) ive got a ProductID field which auto incrmements for every product added. What im trying to do it display the next ProductID on the form so that the user can see what number product it is on the system.
this is how im trying to do it:
Private Sub Form_load()
Set dbs = CurrentDb
Dim mysql As String
Set mysql = "SELECT MAX(ProductID) FROM tblProduct;"
Set prodno = dbs.OpenRecordset("mysql", dbOpenDynaset)
txtProdID.Value = prodno([ProductID])
End Sub
Now with this im trying to add it to my Access table but its showing as NULL Value.
This is the way im trying to add it:
addprod.AddNew
addprod([ProductID]) = txtProdID.Value
addprod([Description]) = txtDescription.Value
addprod([Category]) = cbCategory.Value
addprod([Size]) = txtSize.Value
addprod([Quantity]) = txtQuantity.Value
addprod([Price]) = "£" + txtPrice.Value
addprod.Update
addprod.Bookmark = addprod.LastModified
MsgBox ("Prouct successfully added")
Could anyone help and tell me why its not working??
I get Error code '91'.
Need urgent help Please.
Im making a form which allows the user to add products to the database i have created.
Now in my table (tblProduct) ive got a ProductID field which auto incrmements for every product added. What im trying to do it display the next ProductID on the form so that the user can see what number product it is on the system.
this is how im trying to do it:
Private Sub Form_load()
Set dbs = CurrentDb
Dim mysql As String
Set mysql = "SELECT MAX(ProductID) FROM tblProduct;"
Set prodno = dbs.OpenRecordset("mysql", dbOpenDynaset)
txtProdID.Value = prodno([ProductID])
End Sub
Now with this im trying to add it to my Access table but its showing as NULL Value.
This is the way im trying to add it:
addprod.AddNew
addprod([ProductID]) = txtProdID.Value
addprod([Description]) = txtDescription.Value
addprod([Category]) = cbCategory.Value
addprod([Size]) = txtSize.Value
addprod([Quantity]) = txtQuantity.Value
addprod([Price]) = "£" + txtPrice.Value
addprod.Update
addprod.Bookmark = addprod.LastModified
MsgBox ("Prouct successfully added")
Could anyone help and tell me why its not working??
I get Error code '91'.
Need urgent help Please.