How to validate one calculated field against another calculated fi

C

CTJ

I have 6 text boxes where

[Textbox1] + [Textbox2] = [Textbox3] and
[Textbox4] + [Textbox5] = [Textbox6]

Textbox 1,2,4 and 5 are captured by the user, Textbox 3 and 6 are
caluculated. I want to validate that Text box 3 and 6 equal each other and
where they don't, a warning message is given and user is unable to proceed
before correcting position.

Thanks
 
K

Klatuu

Use the Form's Before Update event to check the condition. You can present a
message box and cancel the update at that time:

With Me
If .TextBox3 <> .TextBox6 Then
MsgBox "TestBox 3 Must Equal TextBox 6"
Cancel = True
End If
End With
 
C

CTJ

That works fine for the validation and warning message, so thanks for that!

However, once I've clicked OK on the message, I want the focus to go back to
TextBox 1. Is that possible?

Regards
CTJ

Klatuu said:
Use the Form's Before Update event to check the condition. You can present a
message box and cancel the update at that time:

With Me
If .TextBox3 <> .TextBox6 Then
MsgBox "TestBox 3 Must Equal TextBox 6"
Cancel = True
End If
End With
--
Dave Hargis, Microsoft Access MVP


CTJ said:
I have 6 text boxes where

[Textbox1] + [Textbox2] = [Textbox3] and
[Textbox4] + [Textbox5] = [Textbox6]

Textbox 1,2,4 and 5 are captured by the user, Textbox 3 and 6 are
caluculated. I want to validate that Text box 3 and 6 equal each other and
where they don't, a warning message is given and user is unable to proceed
before correcting position.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top