If 1 Text Box = Multiple Text Boxes Then

Adam McReynolds

Registered User.
Local time
Today, 11:36
Joined
Aug 6, 2012
Messages
129
I am having trouble figuring out how to separate the the other text boxes. I tried a semi-colon and the commas. Any suggestions?

Code:
If Me.txt_rid1 = ([Me.txt_rid2] , [Me.txt_rid3] , [Me.txt_rid4] , [Me.txt_rid5] , [Me.txt_rid6] , [Me.txt_rid7] , [Me.txt_rid8] , [Me.txt_rid9] , [Me.txt_rid10]) Then
 
Is this what you're after?

If Me.txt_rid1 = Me.txt_rid2 OR Me.txt_rid1 = Me.txt_rid3 OR ...
 
Is this what you're after?

If Me.txt_rid1 = Me.txt_rid2 OR Me.txt_rid1 = Me.txt_rid3 OR ...

Yes, and I went with that but I though there was a separator so they could be listed as "any of these". I think it just because I remembered having a problem with the Or's before. Thank you.
 
A compact alternative is to use the Select Case statement.

Code:
With Me
    Select Case .txt_rid1
    Case .txt_rid2, .txt_rid3, .txt_rid4
        {actions if any match}
    Case Else
        {actions if no match}
    End Select
End With
 
A compact alternative is to use the Select Case statement.

Code:
With Me
    Select Case .txt_rid1
    Case .txt_rid2, .txt_rid3, .txt_rid4
        {actions if any match}
    Case Else
        {actions if no match}
    End Select
End With

Ok, thanks I will try that and report back. I'm guessing the Me at the top means you don't have to apply it to each text box?
 
I'm guessing the Me at the top means you don't have to apply it to each text box?

Yes. That is the With construct. Very useful.

It works with any reference and can make the code a lot easier to read especially when referring to something biger than Me.

Code:
With Forms!someform.somesubform.Form.somecontrol
    .someproperty = whatever
    .anotherproperty = something
End With

Imagine writing that out in full if you wanted to adjust a lot of properties.:eek:
 

Users who are viewing this thread

Back
Top Bottom