MackMan
Registered User.
- Local time
- Today, 06:18
- Joined
- Nov 25, 2014
- Messages
- 174
Quick one...
I have two subforms. The first is a summary form and carries a "TotalCredit" field across to another subform in Datasheet mode where the total credit is being broken down to individual postings, giving me a breakdown of the "TotalCredit" on the first form. These totals should always match.
However, as simple as it sounds, I'm struggling with a msgbox to check if they actually do agree. If so, then carry on and exit the datasheet subform and return me to the main subform to carry on entering data, but if not, then throw me a critical box up and say I'm no good, and totally rubbish at maths
If I purposely ensure the values aren't equal I've tried various ways round, and what ever I do, it'll throw up the msgbox then tell me I'm useless, and then move on to the other subform anyway, or If I try to figure out what's going on, it'll just carry on anyway, as if all is well.. which it isn't.
I'm aware that this is just a couple of lines of VBA, but for my life, I'm just not getting it... I must be having a brain freeze day!
Private Sub frmPosts_Exit(Cancel As Integer)
If [Forms]![frmtopline]![frmPosts].[Form]![txtposttotalcredit] <> [Forms]![frmtopline]![frmTopLineSub].[Form]![Credit] Then
MsgBox "Credits do not agree!", vbCritical, "Verify!"
[Forms]![frmtopline]![frmPosts].SetFocus
[Forms]![frmtopline]![frmPosts].[Form]![Credit].SetFocus
End If
End Sub
I have two subforms. The first is a summary form and carries a "TotalCredit" field across to another subform in Datasheet mode where the total credit is being broken down to individual postings, giving me a breakdown of the "TotalCredit" on the first form. These totals should always match.
However, as simple as it sounds, I'm struggling with a msgbox to check if they actually do agree. If so, then carry on and exit the datasheet subform and return me to the main subform to carry on entering data, but if not, then throw me a critical box up and say I'm no good, and totally rubbish at maths
If I purposely ensure the values aren't equal I've tried various ways round, and what ever I do, it'll throw up the msgbox then tell me I'm useless, and then move on to the other subform anyway, or If I try to figure out what's going on, it'll just carry on anyway, as if all is well.. which it isn't.
I'm aware that this is just a couple of lines of VBA, but for my life, I'm just not getting it... I must be having a brain freeze day!
Private Sub frmPosts_Exit(Cancel As Integer)
If [Forms]![frmtopline]![frmPosts].[Form]![txtposttotalcredit] <> [Forms]![frmtopline]![frmTopLineSub].[Form]![Credit] Then
MsgBox "Credits do not agree!", vbCritical, "Verify!"
[Forms]![frmtopline]![frmPosts].SetFocus
[Forms]![frmtopline]![frmPosts].[Form]![Credit].SetFocus
End If
End Sub