First, is the price over 2500? IF so, return message, delete values. 2nd - Look at the overall value of all
BOM items. Is the total (regardless of the line item) over 7500? If so, run 2nd message (blue sub below).
The problem is this: In testing, if I put a price value of 2499 and quantity of up to 3 and click the 'save' button,
it works fine since overall value is still under 7500. If I change quantity to 4 and click, I still don't get the overall
error message desired. However, if I click the button a 2nd time without doing anything else, I get the correct
results - the error message to the user. I have tried several variations, and adding refreshes and requeries, but
nothing seems to help. I added this line: 'MsgBox Me.SumMsg.Value to help me troubleshoot. If I change
quantity to 4, the first time I click the button, it gives me a value of '2' (the 'safe' value number I've given). If I
click the button a 2nd time without changing anything else, it gives me a value of '1' (the value that prompts the
error message).
I can't expect the user to click the button twice to get around this, and have tried to simulate that effect behind
the scenes. Where am I going wrong in my code or thinking? Thank you so much.
CODE
Private Sub cmdRefresh_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
Forms!XXXXX!XXXXBOMsfrmLineItem.Form.Refresh
Forms!XXXX!XXXXBOMsfrmLineItem.Form.Requery
If Me.ExtPriceMsg.Value = "1" Then
MsgBox "WARNING - The price for this item EXCEEDS $2,500.00. Please refer to the " & _
"instructions on line item limits and revise this line item.", vbCritical, "Price Exceeded!"
MsgBox "Your existing values for this line item will be deleted, you must revise before continuing."
Me.QTY = ""
Me.Price = ""
Else
End If
'MsgBox Me.SumMsg.Value
[color="red"]Call cmdRecalc_Click[/color]
End Sub
[color="blue"]Private Sub cmdRecalc_Click()
Me.Refresh
If Me.SumMsg.Value = "1" Then
Const cTIME = 1000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "WARNING - The total extended value for this order (including TAX and FREIGHT), " & _
"EXCEEDS $7,500.00. Please refer to the instructions on line item limits and revise line it" & _
"ems as needed.", vbCritical, "Value Exceeded!"
Else
End If
Me.Requery
End Sub[/color]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
Forms!XXXXX!XXXXBOMsfrmLineItem.Form.Refresh
Forms!XXXX!XXXXBOMsfrmLineItem.Form.Requery
If Me.ExtPriceMsg.Value = "1" Then
MsgBox "WARNING - The price for this item EXCEEDS $2,500.00. Please refer to the " & _
"instructions on line item limits and revise this line item.", vbCritical, "Price Exceeded!"
MsgBox "Your existing values for this line item will be deleted, you must revise before continuing."
Me.QTY = ""
Me.Price = ""
Else
End If
'MsgBox Me.SumMsg.Value
[color="red"]Call cmdRecalc_Click[/color]
End Sub
[color="blue"]Private Sub cmdRecalc_Click()
Me.Refresh
If Me.SumMsg.Value = "1" Then
Const cTIME = 1000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "WARNING - The total extended value for this order (including TAX and FREIGHT), " & _
"EXCEEDS $7,500.00. Please refer to the instructions on line item limits and revise line it" & _
"ems as needed.", vbCritical, "Value Exceeded!"
Else
End If
Me.Requery
End Sub[/color]
Edited by: NoahP on Wed Jun 13 10:09:09 EDT 2007.