subtrating 1 field from another in 2 seperate forms
Ok....
I have an item form with a field called Stock in it. This is the current stock of each particular item.
In my Sale form I have added a subform of my item form as some had suggested this too me.
I click add record choose the item that has been sold from a combo box, i then choose how many are sold and the date of when they were sold.
Then i click save record to keep it. When i press this i want it to update the current stock by subtracting the quantity sold to get a new value.
This is the code i currently have for my Save button
VB Code:
Private Sub save_Click()
Dim stock As Integer
stock = stock - Quantity
On Error GoTo Err_save_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_save_Click:
Exit Sub
Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub
But it doesn't work.
I hope this explains my problem.
Edit: Fixed [vbcode][/vbcode] tags. - Hack
Andrew
Re: subtrating 1 field from another in 2 seperate forms
this should be in database development.... but try this..
first:
remove..
Dim stock As Integer
then.. note the Me.Stock...
when you type me then "." a list should popup..
is stock in the list? if so.. pick it... then do the same for
quantity...
this should work then
VB Code:
Private Sub save_Click()
On Error GoTo Err_save_Click
me.stock = me.stock - me.Quantity
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_save_Click:
Exit Sub
Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub
Re: subtrating 1 field from another in 2 seperate forms
just had a thought.. if quantity or stock is on another form u need to specify the form name instead of me
form_frmName.stock
Re: subtrating 1 field from another in 2 seperate forms
Access VBA question moved to Office Development
Re: subtrating 1 field from another in 2 seperate forms
Thanks alot!
Problem solved
Andrew
Re: subtrating 1 field from another in 2 seperate forms