My code is:
Private Function CreateID() As Integer
'finds the current highest ID
For Each row As DataRow In MedDT.Rows
If row.Item("MedicineID") > CreateID Then
CreateID = row.Item("MedicineID")
End If
Next
'returns a value for eventID that is unused as its higher then the current highest
Return CreateID
End Function
It should automatically generate a number which is one higher than the highest value in the DataTable but for some reason it isn't working I call the procedure in the Form_Load procedure to fill a text box.