If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
wildcards in an If statement
I am trying to make a text box visible according to the value in a
combo box. I used the If statement posted in a previous post to evaluate for a single value, but I need to show the text box if a specific number is followed by a letter. i.e. 34A, 34B, etc. I've tried the * and ? wildcards without success. Any help will be greatly appreciated. Thanks again, Justin |
#2
|
|||
|
|||
wildcards in an If statement
"Justin" wrote in message
... I am trying to make a text box visible according to the value in a combo box. I used the If statement posted in a previous post to evaluate for a single value, but I need to show the text box if a specific number is followed by a letter. i.e. 34A, 34B, etc. I've tried the * and ? wildcards without success. Any help will be greatly appreciated. It would be helpful to know what you tried, but something like this should work: If Me.ComboBox1 Like "34*" Then Me.TextBox2.Visible = True Else Me.TextBox2.Visible = False End If That can be simplified to: Me.TextBox2.Visible = (Me.ComboBox1 Like "34*") -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#3
|
|||
|
|||
wildcards in an If statement
On Oct 26, 3:37*pm, "Dirk Goldgar"
wrote: "Justin" wrote in message ... I am trying to make a text box visible according to the value in a combo box. I used the If statement posted in a previous post to evaluate for a single value, but I need to show the text box if a specific number is followed by a letter. i.e. 34A, 34B, etc. I've tried the * and ? wildcards without success. Any help will be greatly appreciated. It would be helpful to know what you tried, but something like this should work: * * If Me.ComboBox1 Like "34*" Then * * * * Me.TextBox2.Visible = True * * Else * * * * Me.TextBox2.Visible = False * * End If That can be simplified to: * * Me.TextBox2.Visible = (Me.ComboBox1 Like "34*") -- Dirk Goldgar, MS Access MVP Access tips:www.datagnostics.com/tips.html (please reply to the newsgroup) Many thanks Dirk. So far this is exactly what I was after. I used the If statement and nested several ElseIf statements to accomplish what I wanted to do. In case this might help others: If Me.Route Like "34*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "31*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "63*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "69*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "60*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "85*" Then Me.Fl_Miles.Visible = True Else Me.Fl_Miles.Visible = False End If I placed this code in the Private Sub Form_Current() section of the form. Now I can add a few more If statements to hide/show other text boxes. Thanks again Justin Thomas |
#4
|
|||
|
|||
wildcards in an If statement
You could save a bit of typing and make adding additional critera easier.
Here is how you could do it using the Switch function: Me.TextBox2.Visible = Nz(switch(x like "31*",true, x like "34*", true, x like "60*", true, x like "63*", true, x like "69*",true x like "85*"), false) -- Dave Hargis, Microsoft Access MVP "Justin" wrote: On Oct 26, 3:37 pm, "Dirk Goldgar" wrote: "Justin" wrote in message ... I am trying to make a text box visible according to the value in a combo box. I used the If statement posted in a previous post to evaluate for a single value, but I need to show the text box if a specific number is followed by a letter. i.e. 34A, 34B, etc. I've tried the * and ? wildcards without success. Any help will be greatly appreciated. It would be helpful to know what you tried, but something like this should work: If Me.ComboBox1 Like "34*" Then Me.TextBox2.Visible = True Else Me.TextBox2.Visible = False End If That can be simplified to: Me.TextBox2.Visible = (Me.ComboBox1 Like "34*") -- Dirk Goldgar, MS Access MVP Access tips:www.datagnostics.com/tips.html (please reply to the newsgroup) Many thanks Dirk. So far this is exactly what I was after. I used the If statement and nested several ElseIf statements to accomplish what I wanted to do. In case this might help others: If Me.Route Like "34*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "31*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "63*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "69*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "60*" Then Me.Fl_Miles.Visible = True ElseIf Me.Route Like "85*" Then Me.Fl_Miles.Visible = True Else Me.Fl_Miles.Visible = False End If I placed this code in the Private Sub Form_Current() section of the form. Now I can add a few more If statements to hide/show other text boxes. Thanks again Justin Thomas . |
#5
|
|||
|
|||
wildcards in an If statement
"Klatuu" wrote in message
... You could save a bit of typing and make adding additional critera easier. Here is how you could do it using the Switch function: Me.TextBox2.Visible = Nz(switch(x like "31*",true, x like "34*", true, x like "60*", true, x like "63*", true, x like "69*",true x like "85*"), false) Good idea. I was trying to think of a concise way to express that case structure, but I didn't think of the Switch function. -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#6
|
|||
|
|||
wildcards in an If statement
On Oct 26, 5:48*pm, "Dirk Goldgar"
wrote: "Klatuu" wrote in message ... You could save a bit of typing and make adding additional critera easier. |
#7
|
|||
|
|||
wildcards in an If statement
On Oct 27, 3:37*pm, Justin wrote:
On Oct 26, 5:48*pm, "Dirk Goldgar" wrote: "Klatuu" wrote in message ... You could save a bit of typing and make adding additional critera easier. Here is how you could do it using the Switch function: Me.TextBox2.Visible = Nz(switch(x like "31*",true, x like "34*", true, x like "60*", true, x like "63*", true, x like "69*",true x like "85*"), false) Good idea. *I was trying to think of a concise way to express that case structure, but I didn't think of the Switch function. -- Dirk Goldgar, MS Access MVP Access tips:www.datagnostics.com/tips.html (please reply to the newsgroup) Thanks, Dave, I'll give that a try. I'm glad that I posted my code to get another opinion. Justin Thanks again, Dirk and Dave. This worked like a charm. This allowed me to tighten up my form by placing some of the text boxes on top of each other and having them only appear when needed. Justin |
Thread Tools | |
Display Modes | |
|
|