Hello,
If you care, this is a continuation of a post I wrote on 3/12 about "Inventory Tracking..." I have not been able to make your suggestions work - I think I boxed myself into a corner because of dropdown boxes, format, and subforms. Anyway, this is my new solution to flag against creating negative inventory - but of course this poses a new problem...
The user will enter the products to sell into an invoice form. When they go to save/process the order, a form will pop up that lists:
item id# item name quantity of item requested current inventory of item
all of the info is pulled from a query based on the data entered into the form, exept the "current inventory of item" - which is pulled from another query using DLookup.
All of this works great! I realized I had to use a continuous form or datasheet format for this form because a user will want to sell more than one item. The final piece to this puzzle is that I wanted to write an If-then statement to flag those items ordered that would create a negative value and thus stop the order saving process. I wrote the following if-then statement to check the values of quantity ordered vs. quantity on hand and to put a message in a text box. PROBLEM IS that the code only runs one time and gives that value to all the instances of the text box on my continuous form. How would I tell the code to run per each instance / row that appears on the form??
Private Sub Form_GotFocus()
Dim strInv As Integer ' true inventory quantity on hand
Dim strQ As Integer 'quantity requested to sell
strInv = Val(InvTrue)
strQ = Val(Qty)
TextMsg.SetFocus
If strInv < Qty Then TextMsg.Text = "Rejected"
If strInv > Qty Then TextMsg.Text = "ok"
End Sub
If you care, this is a continuation of a post I wrote on 3/12 about "Inventory Tracking..." I have not been able to make your suggestions work - I think I boxed myself into a corner because of dropdown boxes, format, and subforms. Anyway, this is my new solution to flag against creating negative inventory - but of course this poses a new problem...
The user will enter the products to sell into an invoice form. When they go to save/process the order, a form will pop up that lists:
item id# item name quantity of item requested current inventory of item
all of the info is pulled from a query based on the data entered into the form, exept the "current inventory of item" - which is pulled from another query using DLookup.
All of this works great! I realized I had to use a continuous form or datasheet format for this form because a user will want to sell more than one item. The final piece to this puzzle is that I wanted to write an If-then statement to flag those items ordered that would create a negative value and thus stop the order saving process. I wrote the following if-then statement to check the values of quantity ordered vs. quantity on hand and to put a message in a text box. PROBLEM IS that the code only runs one time and gives that value to all the instances of the text box on my continuous form. How would I tell the code to run per each instance / row that appears on the form??
Private Sub Form_GotFocus()
Dim strInv As Integer ' true inventory quantity on hand
Dim strQ As Integer 'quantity requested to sell
strInv = Val(InvTrue)
strQ = Val(Qty)
TextMsg.SetFocus
If strInv < Qty Then TextMsg.Text = "Rejected"
If strInv > Qty Then TextMsg.Text = "ok"
End Sub