VBjavaFriend
MIS
Is there a way to change a value in another form/table from a different form? For instance, I have a form called customer invoices. When the user is finished entering a part number I want to open the inventory form and deduct the quantity of the part number from inventory based on the quantity on the invoice. Here is my code, but it doesn't work.
Private Sub cmdOpenInventoryForm_Click()
On Error GoTo Err_cmdOpenInventoryForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Inventory"
stLinkCriteria = "[PartNumber]=" & "'" & Me![cmbPartNum1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If [Customer Invoices].Form![txtQuantity1] > 0 Then
[Inventory].Form![Units In Stock] = ([Inventory].Form![Units In Stock] - [Customer Invoices].Form![txtQuantity1])
End If
Exit_cmdOpenInventoryForm_Click:
Exit Sub
Err_cmdOpenInventoryForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenInventoryForm_Click
End Sub
What am I doing wrong? OR is this impossible to do? Somebody told me the only way to do this is by using a subform (inventory) on the invoice form. I really don't want to have to do this because I like the layout of my invoice. Can anyone help me?
Private Sub cmdOpenInventoryForm_Click()
On Error GoTo Err_cmdOpenInventoryForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Inventory"
stLinkCriteria = "[PartNumber]=" & "'" & Me![cmbPartNum1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If [Customer Invoices].Form![txtQuantity1] > 0 Then
[Inventory].Form![Units In Stock] = ([Inventory].Form![Units In Stock] - [Customer Invoices].Form![txtQuantity1])
End If
Exit_cmdOpenInventoryForm_Click:
Exit Sub
Err_cmdOpenInventoryForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenInventoryForm_Click
End Sub
What am I doing wrong? OR is this impossible to do? Somebody told me the only way to do this is by using a subform (inventory) on the invoice form. I really don't want to have to do this because I like the layout of my invoice. Can anyone help me?