Combo Box Conundrum

jeremy.lankenau

Registered User.
Local time
Today, 15:36
Joined
Feb 19, 2015
Messages
32
Hi all,

Question regarding the Combo Box. I've searched all over the site (which I've used often when I've been stuck) and on google, and cannot seem to find the right answer to my issue:

I work in the HR Labor and Management Employee Relations field, and so we take various actions - Disciplinary, Performance, Reasonable Accomodation, Grievance's, etc.

I have a form - fAction, which contains a combobox Type_Of_Action. It is a value list which specifies the types of actions in the PP above. If Type_Of_Action has Disciplinary, selected, I have a hidden checkbox (DiscDecIssued) that is changes from hidden with 0 height to visible and 315.072 twips:

Private Sub Type_of_Action_Change()
If Type_of_Action.Value = "Disciplinary" Then
Me.DiscDecIssued.Visible = True
Me.DiscDecIssued.Height = 315.072
Me.Label81.Visible = True
Me.Label81.Height = 315.072
Else
Me.DiscDecIssued.Visible = False
Me.DiscDecIssued.Height = 0
Me.Label81.Visible = False
Me.Label81.Height = 0
End If
'1440 twips = 1 inch, so 315.072 twips = 0.2188 inches

End Sub

My problem is that since putting in this code, once a value is selected in the combo box's value list, whether "Disciplinary" or any of the various other values, the Combo Box will not display the selection until I tab off the Combo Box or click onto another field (the code itself works fine). Is there some VBA code I can put in (perhaps AfterUpdate() ) that will force the selected value to appear in the form before the user tabs off or clicks on another field?

I'd like to keep the DiscDecIssued hidden, because I only want it up if Disciplinary is selected. I have other hidden fields that appear if the DiscDecIssued is clicked that take the user through the logical steps (about 10 other fields), but these do not need to be visible unless Type_Of_Action is "Disciplinary" and DiscDecIssued is checked.

Thanks for your help!
Jeremy
 
What if you put your code in the after update event instead?
 
JHB,

Thanks...that did it. Can't believe I didn't to try that as I use AfterUpdate () elsewhere!

Jeremy
 
you really only need the visible property, and leave your control heights as what is required - and assuming Label81 is associated with DiscDecIssued then it will also become visible as well.

You also do not need to refer to the value property since that is the default

so you can simplify your code considerably to just

Code:
 Private Sub Type_of_Action_AfterUpdate()
    DiscDecIssued.Visible = Type_of_Action = "Disciplinary" 
 end sub
 
CJ,

When I do that, it keeps the placeholder space in the form, leaving a bunch of blank white space. I'm using Access 2007. Is there another way around that? I would do this if it were at the bottom of the form, but it is in the middle, and combined with the 7 or 8 other fields I am doing the same way, using the line you provided, while simpler, would leave white space because the form doesnt adjust automatically to close the placeholder space when the field isnt visible.

Jeremy
 
it keeps the placeholder space in the form
Ah, not a feature I use, in fact I'd completely forgotten about it:D.

Regret I don't know a workaround that would be any different to what you are doing at the moment.
 
JHB,

Thanks...that did it. Can't believe I didn't to try that as I use AfterUpdate () elsewhere!

Jeremy
You're welcome. Sometimes you get fixed to a problem that we forget it could be other ways. :)
 

Users who are viewing this thread

Back
Top Bottom