Function IF with List

krzysiekk

Registered User.
Local time
Today, 14:01
Joined
Dec 2, 2009
Messages
74
Hi I had in form with box list and some subforum

When I open forum showing few values in box list and opposite subform.
I want hide subform when open form and box list is unselected after select value in box list subform should be visible.

I try use event in form (with open)

If IsNull(Me.List49) Then
Me.vacancy_sub.Visible = False
Else
Me.vacancy_sub.Visible = True
End If

But not working... please help me
 
Put the form in design view and insert a Break Point in the code at the IF statement. You do this by clicking in the grey border to the left of the point at which you want to stop the code (see the attachment for an example)

Now change to Form View. The code will stop at the break point and the code window will come to the foreground with the break point line high lighted in yellow. Now hover your cursor over the (Me.List49) portion of the code, a small window will appear with the value held in (Me.List49), I suspect that it will not be Null.
 

Attachments

Actually, you could get a Null value from the listbox if the row source returns no record or if there's no row source.

You could probably do it like this:
Code:
Me.vacancy_sub.Visible = (Len(Me.List49 & "")<>0 And  (Me.List49.ListIndex > -1))
This ensures that a value is selected and the bound column has a value.

Put this code in two places:
1. On Current event of the form
2. After Update event of the listbox
 
And if the listbox has Multi-Select set to YES then it will ALWAYS return a null value. You would need to iterate through the list box or the itemsSelected collection to get the values.
 
My supposition was based merely on the fact that the code in the OP was not working, hence my suggestion to put a break point in and see what value List49 was holding.
 
And I had just mentioned the part about null due to it not being mentioned at all. I think between us all, we might just crack it :D.
 

Users who are viewing this thread

Back
Top Bottom