Can I Open a list box at a Specific Location on Form?

C

Chertsey

I have a form with various list boxes already. I would like to make a hidden
list box appear directly below the selected item of lstBox1. Here is what I
am looking for.
lstBox1 contains a listing of Schools. When I select a School, I would like
a Listbox of the staff at THAT schooll to appear. AND have it apear directly
under the selected School. Is this possible?
Thanks for any help!
BTW: I am using Access 2003
 
J

Jack Leach

You might take a look at these properties of the control

Me.Control.Top (spacing from top of section)
Me.Control.Left (spacing from left of form)
Me.Control.Visible (toggle visible true or false)

Note that the units accepted by the Top and Left properties are in Twips: 1
inch = 1440 Twips.

With these you should be able to, from the desired Event procedure, position
and display the said control wherever and however you like.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

But another way might be just to modify the RowSource of the listbox...
rather than having multiple listboxes for each school, requery the ListBox
box with a new rowsource


Me.ListBox.RowSource = "SELECT * FROM tblSchools " & _
"WHERE SchoolID = " & YourSchoolID


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

Dale Fye

Chertsey,

Generally, if I have cascading combo or list boxes, I put them side by side
on my form, so I had never tried what you are asking for.

At first blush, the key here is figuring out which position in the list your
mouse is hovering over when you select the item. The best way to do that is
to use the MouseUp event of the list, since it fires after the click event,
and contains a parameter (Y) that indicates the vertical offset of the mouse
from the top of the list control.

I played around with this a little, but am not happy with the results. The
problem is that even though I have used the Position option to send the first
list to back and brought the second list to front, the first list seems to
overlay the second when I move it. I'm sure there is probably a way to
programmatically move the second listbox control to the forefront, but have
not figured out how to do that.

Private Sub List0_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)

Me.List2.Move Me.List0.Left + 500, Me.List0.Top + Y
Me.List2.Visible = True
Me.List2.SetFocus

End Sub

Play around with this a little. If that doesn't accomplish what you want,
consider creating a popup form that you open with the staff listed in a
listbox on the popup. then, when the users selects the staff member, just
populate the appropriate field in your main form.
 
C

Chertsey

Thanks for trying Dale.
I ran into the same issues you did re the main list being infront of the pop
up list. It seems to cause too many problems when tryin to select an item
from iether list. I am now considering and working on a pop up form (as you
indicate).
The users are seeing more and more "neat" things all around the web these
days and are beginning to ask for them in Access. It's frustrating when i
can't seem to at least emulate what's out there. This seems to be a perfect
example. A list box that pops up/down more info about the selected item. I'll
keep playing though....
Thanks again guys.
 
D

Dale Fye

another option would be to use cascading combo boxes, rather than lists. Not
much different functionality, but much less screen realestate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top