|
-
Jan 10th, 2006, 01:59 PM
#1
Thread Starter
New Member
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
-
Jan 10th, 2006, 02:12 PM
#2
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
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 10th, 2006, 02:14 PM
#3
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
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 10th, 2006, 02:25 PM
#4
Re: subtrating 1 field from another in 2 seperate forms
Access VBA question moved to Office Development
-
Jan 10th, 2006, 03:41 PM
#5
Thread Starter
New Member
Re: subtrating 1 field from another in 2 seperate forms
Thanks alot!
Problem solved
Andrew
-
Jan 10th, 2006, 03:41 PM
#6
Member
Re: subtrating 1 field from another in 2 seperate forms
HALF LIFE 2 for president
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|