Cascade list boxes

F

fourstar

I have a form that utilizes one list box to update another. Listbox1
contains a row of times relative to a date selected by the user.
Listbox2 contains a list of names relative to the times in Listbox1.
When the user clicks a time in listbox1, listbox2 is updated to reflect
the names associated with that time. The problem I am trying to fix
is: When the user selects a date that does not have any times
associated with it, listbox1 is blank, as it should be, but listbox2
continues to display data from the date/time previously selected in
listbox1. I am using the requery method to update listbox2 each time
the listbox1 selection changes. Listbox2 just doesn't know what to do
when the boundcolumn in listbox1 is a null value. Any ideas on how to
make listbox2 go clear when listbox1 is clear?
 
D

Douglas J. Steele

Sounds as though you've got a reference to listbox1 in the query that forms
the recordset for listbox2, something like
SELECT Field1, Field2 FROM Table2 WHERE Field3 = Forms!MyForm!Listbox1

Try changing that to
SELECT Field1, Field2 FROM Table2 WHERE Field3 = Forms!MyForm!Listbox1 OR
Forms!MyForm!Listbox1 IS NULL

If that's not the case, post back with details of how you're currently
limiting listbox2.
 
F

fourstar

Yes, my list boxes are linked per your post:
SELECT Field1, Field2 FROM Table2 WHERE Field3 = Forms!MyForm!Listbox1

I tried to set the OR Forms!MyForm!Listbox1 Is Null criteria, but whe
I did Listbox2 displays all of the records instead of just the record
previously filtered by the criteria setting. Heres the SQL statemen
the way it is now:

SELECT [Shooter to Relay].[CAD ID], [Shooter to Relay].[Relays ID]
[Shooter to Relay].Day, [Shooter to Relay].Date, [Shooter t
Relay].Starttime, [Shooter to Relay].LNAME, [Shooter to Relay].FNAME
[Shooter to Relay].Department, [Shooter to Relay].[Relay to Shoote
ID]
FROM [Shooter to Relay]
WHERE ((([Shooter to Relay].[Relays ID])=[Forms]![Assign Shooter t
Relay]![All Relay List]));

What is happening is when Relays ID goes from an existing number to
null, the Shooter to Relay listbox should go blank. What is weird i
that when I open the form, if All Relay List is blank, Shooter to Rela
is blank
 

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