Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If-Then results on a continuous form

Status
Not open for further replies.

MilinPCH

Technical User
Jul 27, 2000
37
0
0
US
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 = &quot;Rejected&quot;
If strInv > Qty Then TextMsg.Text = &quot;ok&quot;
End Sub

 
You most understand that continues forms has a problem that if the textbox is unbounded, than each value you will right to this textbox will have an effect on all record, the only work around I have find is to make an extra field in the underlying table and to bound this textbox to that field than each textbox can have a different value.

Jn88
 
If I'm understanding what you wrote, I can't bind a value back to the table/query, since the quantity of items ordered would be different each time. Is the only way around this to create a form with, say 15 lines - space for the user to process 15 records, and then the if-then would work on each instance?

 
I think not (therefore I am Not?),

the &quot;function&quot; needs to be attached to the control in the detail section.

TextMsg.ControlSource:
=IIf(strInv < Qty, &quot;Rejected&quot;, &quot;ok&quot;)

Of course strInv and Qty should be replaced by the FIELD NAMES of their respective sources.



MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top