oxicottin
10-21-2015, 06:59 AM
Hello, I have tried everything on getting this result in a mesage box so I figure mabe looping might give me the result needed but I dont understand how it works and after reading through the web I cant grasp the consept for some reason without an example that pertains to my situation.
Here is the issue im having, I have a main form [frm_Hold] with two subforms [frmsub_ProductHoldData], [fsub_RejectedData] and each sub form is a continious form BUT the main form isnt. Now there is a textbox on each subform..
1) [frmsub_ProductHoldData] with record source [tbl_frmsub_ProductHoldData] and has a textbox txtCartonsHeld with its control source [CartonsHeld]
2) [fsub_RejectedData] with record source [tblsub_RejectedHoldData] and has a textbox txtCartonRejected with its control source [CartonRejected]
Now, I have in the subforms footer a textbox txtSumOfCartonRejected that sums =Sum([CartonRejected]) and same with txtSumOfCartonsHeld =Sum([CartonsHeld]). What I need to do is when I enter an number in txtCartonsHeld it needs to check and see if new SUM would be less than txtSumOfCartonRejected and if so have a message and in the subforms textbox txtCartonRejected when I enter a number it will check to see if is not greater than the toal sum of [CartonsHeld]
Like this but it doesnt work becuse it doesnt update untill you move focus unto the next record and I need it to work on the before update..
Dim strSumOfRejectRework As String
Dim strSumOfHoldCts As String
Dim cancel As Integer
strSumOfHoldCts = Me.txtSumOfCartonsHeld
strSumOfRejectRework = Nz([Forms]![frm_Hold]![fsub_RejectedData].[Form].[txtSumOfCartonRejected], 0) _
+ Nz([Forms]![frm_Hold]![fsub_ReworkedData].[Form].[txtSumOfCartonReworked], 0)
If strSumOfHoldCts > strSumOfRejectRework Then
MsgBox "Check your totals and try again.", vbInformation
txtCartonsHeld.Undo
cancel = True
End If
Here is the issue im having, I have a main form [frm_Hold] with two subforms [frmsub_ProductHoldData], [fsub_RejectedData] and each sub form is a continious form BUT the main form isnt. Now there is a textbox on each subform..
1) [frmsub_ProductHoldData] with record source [tbl_frmsub_ProductHoldData] and has a textbox txtCartonsHeld with its control source [CartonsHeld]
2) [fsub_RejectedData] with record source [tblsub_RejectedHoldData] and has a textbox txtCartonRejected with its control source [CartonRejected]
Now, I have in the subforms footer a textbox txtSumOfCartonRejected that sums =Sum([CartonRejected]) and same with txtSumOfCartonsHeld =Sum([CartonsHeld]). What I need to do is when I enter an number in txtCartonsHeld it needs to check and see if new SUM would be less than txtSumOfCartonRejected and if so have a message and in the subforms textbox txtCartonRejected when I enter a number it will check to see if is not greater than the toal sum of [CartonsHeld]
Like this but it doesnt work becuse it doesnt update untill you move focus unto the next record and I need it to work on the before update..
Dim strSumOfRejectRework As String
Dim strSumOfHoldCts As String
Dim cancel As Integer
strSumOfHoldCts = Me.txtSumOfCartonsHeld
strSumOfRejectRework = Nz([Forms]![frm_Hold]![fsub_RejectedData].[Form].[txtSumOfCartonRejected], 0) _
+ Nz([Forms]![frm_Hold]![fsub_ReworkedData].[Form].[txtSumOfCartonReworked], 0)
If strSumOfHoldCts > strSumOfRejectRework Then
MsgBox "Check your totals and try again.", vbInformation
txtCartonsHeld.Undo
cancel = True
End If