Via combo box view grouped info -- limit combo on enter, show all when leave

Via combo box view grouped info -- limit combo on enter, show all when leave

Post by strive4pea » Wed, 21 Jun 2006 01:39:55


Hi George,


limit the combobox to specific records when it gets the
focus, show all records when you leave it

on the gotFocus event of the Product combobox, assign this:

=SetRowSource(true)


on the lostFocus event of the Product combobox, assign this:

=SetRowSource(false)


put this code behind the subform with the combobox -- and
compile it before testing

'~~~~~~~~~~~

private function SetRowSource(pBooCriteria as boolean)

on error goto Err_proc

dim s as string, mRecordID as long

s = "SELECT StoreID, StoreName " _
& " FROM Stores"

if pBooCriteria then
mRecordID = nz(me.parent.RecordID_controlname )
if mRecordID <> 0 then
s = s & " WHERE (RecordID_fieldname =" _
& mRecordID & ") "
end if
end if

s = s & "ORDER BY StoreName;"

debug.print s

me.combobox_controlname.RowSource = s
me.combobox_controlname.Requery

exit function

Err_proc:
msgbox err.description,, _
"ERROR " & err.number & " SetRowSource"
'press F8 to step through code and fix problem
Stop
Resume
End function

'~~~~~~~~

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
 
 

1. Combo box list based on information entered in another combo box

2. How to limit combo box list based on value in another combo box?

Hello,

I have a combo-box (#1) that looks up to a lookup table that contains a
series of Adverse Event categories. I want a second combo box that will only
show the Adverse Events themselves based on the Category chosen in Combo Box
#1. My thought was to have the combo box look up to a query that looks
something like this, but it does not work (see code):

SELECT LU_AETest.AESelect
FROM LU_AETest
WHERE (((LU_AETest.AE)=[Me].[AE]))
ORDER BY LU_AETest.AESelect;

where 'LU_AETest' is the lookup table, 'LU_AETest.AESelect' is the AE value
I'm looking to fill in, 'LU_AETest.AE' is the AE category that I'm looking to
match up to the field 'AE' that I've just filled out on the form. All that
happens when I click on the 'AESelect' combo box is 'Me.AE - Enter Parameter
Value'. Once I fill in the AE Category ('AE'), I would like that value to
limit what the user sees for choices of appropriate AE's ('AESelect'). How
can I do this?

Thanks,
--
Pat Dools

3. Combo Box on Main Form and limits Combo Box selection on the Subfo

4. Limiting names displayed in a combo box based on choice in another combo box

5. Limiting content of combo boxes from a previous combo box selectio

6. Limit a combo box by 2 other combo boxes

7. Datasheet View: Second Combo Box Criteria Based on First Combo Box Value

8. Showing combo box results from the results of another combo box

9. How to limit combo box list based on value in another combo bo

10. Limit list of combo box based on selection of another combo

11. filtering or limiting combo/list box from another combo/list b

12. Cascading Combo Box - filling a text box instead of a Combo box

13. Combo Box - Hide Combo Box w/Check Box

14. Showing combo box results from the results of another combo bo

15. entering Info in Combo box