I started messing about with VBA yesterday (I'm a newbie at this language) and have run across a problem which i hope you can help me with.
I'm writing a little stock control program in clicking a command button opens a message box which asks for a number of items to add to the currently displayed record in the main form (called Parts).
You's think this would be simple and i have some code which i have cobbled together which I would work if I could keep the record from zipping back to record 1 everytime I save to the "current_Stock" field.
The main form has previous/next record buttons and a fairly standard "search by dropdown box" which all seems to be working.
So what I'm working toward is ;
Select record by search or prev/next button
Click Command button to add inventory stock
Enter value in message box
Value is added to current record/current_stock field
messagebox closes revealing updated record.
Expand|Select|Wrap|Line Numbers
- Private Sub Command83_Click()
- On Error GoTo Err_Command83_Click
- Dim intTemp As Integer
- Dim Vtemp As Integer
- Dim Resultant As Integer
- Vtemp = CurrentDb.OpenRecordset("SELECT * FROM Part")(12)
- intTemp = InputBox("Sub Current Stock", "Add Stock", 0)
- Me.Current_Stock = intTemp + Vtemp
- Exit_Command83_Click:
- Me.Requery
- Exit Sub
- Err_Command83_Click:
- MsgBox "Chris has officially cocked up!" & vbCrLf & vbCrLf & "With the Error No: " & Err.Number & vbCrLf & Err.Description
- Resume Exit_Command83_Click