if statement in text box (1 Viewer)

daameta

Registered User.
Local time
Today, 09:19
Joined
May 26, 2015
Messages
25
hi i am back with new question. i have a form name as form1 with 4 text box.
txt1
txt2
txt3
txt4
i have a conditional statement in txt1 like
if txt1 have any value than txt2 or txt3 will be enable for data entry other wise disable so user cannot enter data in txt1 or txt2.
is it possible? please reply me code.
 

vbaInet

AWF VIP
Local time
Today, 17:19
Joined
Jan 22, 2010
Messages
26,374
Is this a Forms or Reports question daameta?

You can either use Conditional Formatting (depending on the view of your "form") or just write it in code in the After Update event of the txt1 and the Current event of the form:
Code:
If Len(Me.txt1 & vbNullString) <> 0 Then
    Me.txt2.Enabled = True
    Me.txt3.Enabled = True
Else
    Me.txt2.Enabled = False
    Me.txt3.Enabled = False
End If

Or the shorter version:
Code:
Me.txt2.Enabled = (Len(Me.txt1 & vbNullString) <> 0)
Me.txt3.Enabled = (Len(Me.txt1 & vbNullString) <> 0)
... the right hand side evaluates to True when the condition is met, or False when it isn't.
 

daameta

Registered User.
Local time
Today, 09:19
Joined
May 26, 2015
Messages
25
Is this a Forms or Reports question daameta?

You can either use Conditional Formatting (depending on the view of your "form") or just write it in code in the After Update event of the txt1 and the Current event of the form:
Code:
If Len(Me.txt1 & vbNullString) <> 0 Then
    Me.txt2.Enabled = True
    Me.txt3.Enabled = True
Else
    Me.txt2.Enabled = False
    Me.txt3.Enabled = False
End If

Or the shorter version:
Code:
Me.txt2.Enabled = (Len(Me.txt1 & vbNullString) <> 0)
Me.txt3.Enabled = (Len(Me.txt1 & vbNullString) <> 0)
... the right hand side evaluates to True when the condition is met, or False when it isn't.
thanks for your code
in my case first code is useful for me. the other one make txt2 or txt3 all time disable.
 

Users who are viewing this thread

Top Bottom