N
Nathan D Clark
I am running Access 2007. I have two listboxes sitting side by side on the
same form.
One has phone number categories - lstCategories
The second listbox has name, phone numbers - lstPhoneNumbers
Both listboxes are unbound
I had this working once where you could click the category in the first box
and it would filter the second listbox to the phone number in a different
category.
Example:
click category box select family, friend etc.
the second box would only show numbers of family or category you selected in
the first box.
Now, the boxes work perfectly fine as far as retrieving the data. The
problem is the Requery code stopped working. I have to actually click a
Refresh button to refresh after clicking the category.
I have two copies of the same DataBase.
On the original DB it works perfectly fine. The copy of this same DB will
not requery after selection of the category. I am lost on why the code
would stop working in the copy.
Here is the code:
Private Sub lstCategories_AfterUpdate()
Me.lstPhoneNumbers.Requery
Me.lstPhoneNumbers = Null
End Sub
Here is the Row Source of the First list box - lstCategories
SELECT [PhoneCategories].[PhoneCategory] FROM PhoneCategories ORDER BY
[PhoneCategory];
Here is the Row Source of the Second listbox - lstPhoneNumbers
SELECT Contacts.ContactID, (FirstName+" ") & LastName, PhoneNumber, Category
FROM Contacts INNER JOIN ContactPhones ON
Contacts.ContactID=ContactPhones.ContactID WHERE
PhoneCategory=Form!lstCategories Or Form!lstCategories Is Null ORDER BY
LastName, FirstName;
same form.
One has phone number categories - lstCategories
The second listbox has name, phone numbers - lstPhoneNumbers
Both listboxes are unbound
I had this working once where you could click the category in the first box
and it would filter the second listbox to the phone number in a different
category.
Example:
click category box select family, friend etc.
the second box would only show numbers of family or category you selected in
the first box.
Now, the boxes work perfectly fine as far as retrieving the data. The
problem is the Requery code stopped working. I have to actually click a
Refresh button to refresh after clicking the category.
I have two copies of the same DataBase.
On the original DB it works perfectly fine. The copy of this same DB will
not requery after selection of the category. I am lost on why the code
would stop working in the copy.
Here is the code:
Private Sub lstCategories_AfterUpdate()
Me.lstPhoneNumbers.Requery
Me.lstPhoneNumbers = Null
End Sub
Here is the Row Source of the First list box - lstCategories
SELECT [PhoneCategories].[PhoneCategory] FROM PhoneCategories ORDER BY
[PhoneCategory];
Here is the Row Source of the Second listbox - lstPhoneNumbers
SELECT Contacts.ContactID, (FirstName+" ") & LastName, PhoneNumber, Category
FROM Contacts INNER JOIN ContactPhones ON
Contacts.ContactID=ContactPhones.ContactID WHERE
PhoneCategory=Form!lstCategories Or Form!lstCategories Is Null ORDER BY
LastName, FirstName;