Show/hide based on combo box answer

Mr. SLP

Registered User.
Local time
Today, 13:24
Joined
Dec 23, 2017
Messages
56
I want to show/hide controls if the answer chosen from a combo box is like “*x*” I can’t seem to get it to work with “like” but can easily make it work if I say = “x” but that’s not ideal because leads to me having to go back in and edit the code as I add items to the combo box list that fit the category.


Sent from my iPhone using Tapatalk
 
I can get it to work with...
If Me.combo = "Whatever" Then
Me.OtherControlName.Visible = True
Else
Me.OtherControlName.Visible = False
End If

What I’m wanting is something like

If Me.combo like "*What*" Then
Me.OtherControlName.Visible = True
Else
Me.OtherControlName.Visible = False
End If


Sent from my iPhone using Tapatalk
 
I can get my idea of the code to work if it references a text box and not a combo box. There’s something about using “like” and not = with a combo box that it is not liking when doing a “if then else”


Sent from my iPhone using Tapatalk
 
And how does that not work? Looks like it should.
 
There’s something about using “like” and not = with a combo box that it is not liking when doing a “if then else”
:D:rolleyes::):D

Either of the following should work

Code:
Private Sub Combo0_AfterUpdate()

    If Me.Combo0 Like "*what*" Then
        Me.Box2.Visible = True
    Else
        Me.Box2.Visible = False
    End If
End Sub

OR ...

Code:
Private Sub Combo0_AfterUpdate()

    If Me.Combo0 Like "*" & "what" & "*" Then
        Me.Box2.Visible = True
    Else
        Me.Box2.Visible = False
    End If
End Sub
 
It throws an error. When I select debug it has the “like” highlighted. If I change it back to a = it doesn’t error but it makes everything fall into the else category if I say “*what*”


Sent from my iPhone using Tapatalk
 
I'll get out of the way.
 
Sorry Paul - you're never in the way.
I'd already typed my first answer based on this quick DB before seeing your reply ...
 
Now I feel stupid. Not sure why I was getting the errors at first but then the second problem is that it’s case sensitive and I didn’t realize that. Thanks.


Sent from my iPhone using Tapatalk
 
Not sure why I was getting the errors at first but then the second problem is that it’s case sensitive and I didn’t realize that.

Now I'm confused.
Case sensitive?

The comparator *what* should work correctly with:
- What, Now what, whatever, what if, so What, WHATSANAME etc etc
 
Yeah I don’t even know because I posted that and then went back and looked at the DB you posted and that made no difference. All I know is that my computer as a whole is being buggy at the second. I just did a full reset hoping that fixes some things... for some reason I was suddenly unable to unable to click into anything within the event tab of the property sheet. However, after rest I could, and that was after trying just closing access as a whole and opening it again.


Sent from my iPhone using Tapatalk
 
Sounds like you need to compact/repair your DB. Hopefully that will resolve issues.
 
Yeah I don’t even know because I posted that and then went back and looked at the DB you posted and that made no difference. All I know is that my computer as a whole is being buggy at the second. I just did a full reset hoping that fixes some things... for some reason I was suddenly unable to unable to click into anything within the event tab of the property sheet. However, after rest I could, and that was after trying just closing access as a whole and opening it again.


Sent from my iPhone using Tapatalk
If you continue to have issues you could try to dim a variable = To the combo box and asses the variable or use a text box that = your combo.

Sent from my SM-G950U using Tapatalk
 

Users who are viewing this thread

Back
Top Bottom