[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB visible function

Posted on 2007-08-02
5
Medium Priority
?
1,350 Views
Last Modified: 2013-12-26
I am trying to make a combo box on a subform visible when the user selects an industry on the main form on the after update event.   Below is my code.  On the combo box property I have it set to visible.  I select the industry and go to the tab with the combo box and nothing appears.  Please help!  Thanks


If Me!LogIndustry Like "Housing Authorities" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = True
ElseIf Me!LogIndustry <> "Housing Authorities" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = False
End If
If Me!LogIndustry Like "Commercial" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = True
ElseIf Me!LogIndustry <> "Commercial" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = False
End If
0
Comment
Question by:gfelton
5 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 19622493
Hello gfelton,

Why are you using the Like operator with no wild cards?

If Me!LogIndustry Like "Housing Authorities" Then

is no different from:

If Me!LogIndustry = "Housing Authorities" Then


Regards,

Patrick
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 19622558
you can try like:


Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = (Me!LogIndustry = "Housing Authorities")

Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = (Me!LogIndustry = "Commercial")
0
 
LVL 5

Accepted Solution

by:
patingsadagat earned 300 total points
ID: 19623998
try this

If LCase(Me!LogIndustry) = "housing authorities" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = True
    Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = False
ElseIf LCase(Me!LogIndustry) = "commercial" Then
    Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = True
    Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = False
Else
    Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = False
    Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = False
End If
0
 

Author Comment

by:gfelton
ID: 19634590
Hi
 I tried all of the possibe solutions.  I can select the first choice as true, but when I change to the second choice I get an error message that states:
"You can't hide the control that has the focus"

Any suggestions?

di
0
 
LVL 54

Assisted Solution

by:Ryan Chong
Ryan Chong earned 75 total points
ID: 19634649
>>"You can't hide the control that has the focus"

try set the focus to other control, before you set your current focused control to invisible?

like:

...
Forms![frmTradeshow]![frmCatalogs].Form![OtherControl].focus()

Forms![frmTradeshow]![frmCatalogs].Form![combo_HA].Visible = (Me!LogIndustry = "Housing Authorities")

Forms![frmTradeshow]![frmCatalogs].Form![combo_Com].Visible = (Me!LogIndustry = "Commercial")
...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question