Private Sub cmdAdd_Click()
Dim sConn As String, xQuantity As Integer, xStockTotal As Integer
Set oConn = New ADODB.Connection
Set rsAdd = New ADODB.Recordset
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\inventory.mdb;Persist Security Info=False"
oConn.Open sConn
If LenB(cmbItemName.Text) = 0 Then
MsgBox "You have to select an item from the drop down list.", vbOKOnly + vbExclamation, "No Selection"
cmbItemName.SetFocus
Exit Sub
ElseIf LenB(txtQuantity.Text) = 0 Then
MsgBox "You have not set a quantity amount to add.", vbOKOnly + vbExclamation, "No Quantity"
txtQuantity.SetFocus
Exit Sub
Else
rsAdd.Open "SELECT Description, [Current Stock] FROM storage WHERE Description = '" & cmbItemName.Text & "'", oConn, adOpenKeyset, adLockOptimistic
xQuantity = txtQuantity.Text
xStockTotal = rsAdd![Current Stock]
xQuantity = xQuantity + xStockTotal
rsAdd![Current Stock] = xQuantity
rsAdd.Open "SELECT Description, [Total Stocks] FROM storage WHERE Description = '" & cmbItemName.Text & "'", oConn, adOpenKeyset, adLockOptimistic
xQuantity = txtQuantity.Text
[U] xStockTotal = rsAdd![Total Stocks]
xQuantity = xQuantity + xStockTotal
rsAdd![Total Stocks] = xQuantity[/U]
MsgBox "Quantity added!", vbOKOnly + vbInformation, "Success"
rsAdd.Update
Form5.DataGrid1.Refresh
rsAdd.Close
oConn.Close
Unload Me
Form5.Adodc1.Refresh
Form5.DataGrid1.Refresh
Form5.Show
End If
End Sub
the underlined code was the problem...Download my attach files to see it for yourself...when i delete the underlined code the program runs perfect but when I add it program error shows...Do I put the wrong code..Pls Help...