Trouble with conditional formatting (1 Viewer)

jjake

Registered User.
Local time
Today, 12:54
Joined
Oct 8, 2015
Messages
291
Hello,

I am currently using the following code in VBA to disable/enable a text box.

Code:
DLookUp("[Department]","[tblUsers]","[UserTag]='" & [Me].[txtUser] & "'")=2

I have tried using this same expression in conditional formatting to enable a different box but it isn't working. Any idea why?
 

bastanu

AWF VIP
Local time
Today, 10:54
Joined
Apr 13, 2010
Messages
1,402
Conditional formatting cannot disable a box, it simply changes the formatting. Try it without Me like:
DLookUp("[Department]","[tblUsers]","[UserTag]='" & [txtUser] & "'")=2

Cheers,
Vlad
 

isladogs

MVP / VIP
Local time
Today, 18:54
Joined
Jan 14, 2017
Messages
18,209
You can easily do this in code

Code:
if DLookUp("[Department]","[tblUsers]","[UserTag]='" & [txtUser] & "'")=2 Then
Me.othertextboxname.Enabled=True
End If

Use this code in a suitable procedure e.g. The after update event of txtUser control
 

jjake

Registered User.
Local time
Today, 12:54
Joined
Oct 8, 2015
Messages
291
Ridders, i currently have this textbox using conditional formatting to enable/disable using the following expression

Code:
[RDReview]=1 And [ProductionReview]=1 And [MaintenanceReview]=1 And [SafetyReview]=1 And [SiteManagerReview]=1

How would i combine this with the code you provided?
 

isladogs

MVP / VIP
Local time
Today, 18:54
Joined
Jan 14, 2017
Messages
18,209
Just combine them like this

Code:
if DLookUp("[Department]","[tblUsers]","[UserTag]='" & [txtUser] & "'")=2 And [RDReview]=1 And [ProductionReview]=1 And [MaintenanceReview]=1 And [SafetyReview]=1 And [SiteManagerReview]=1 Then
     Me.othertextboxname.Enabled=True
End If
 
Last edited:

June7

AWF VIP
Local time
Today, 09:54
Joined
Mar 9, 2014
Messages
5,466
@bastanu, yes ConditionalFormatting can enable/disable.

I agree that Me. must be removed from the ConditionalFormatting expression.

Me. and Me! only work in VBA.
 

Users who are viewing this thread

Top Bottom