I have a form with many combo and list boxes, but i don't know how to find a relation between them. I want to select a name of a product that is in a combobox and then a list or text box will show its description.... Please help me because I will burn out sooner or later
KD
The simplest way is to have your listbox have an underlying query as it's rowsource and in the query have the criteria be the combo box. Then, you just go into the combo box's AfterUpdate event (done by selecting the combo box in design view, clicking on the Event tab in the properties dialog, and selecting EVENT PROCEDURE in the dropdown that appears when you click inside empty box to the right of the words "AfterUpdate" event in the list, and then clicking on the elipsis [...] that appears to the right of that box you just selected EVENT PROCEDURE) and enter
Code:
Me.TypeYourActualListBoxNameHere.Requery
And, just as an FYI, the key word ME is a shortcut in code that refers to the current form that you are on, so in the event for the list box it refers to the form that the list box is on.
The simplest way is to have your listbox have an underlying query as it's rowsource and in the query have the criteria be the combo box. Then, you just go into the combo box's AfterUpdate event (done by selecting the combo box in design view, clicking on the Event tab in the properties dialog, and selecting EVENT PROCEDURE in the dropdown that appears when you click inside empty box to the right of the words "AfterUpdate" event in the list, and then clicking on the elipsis [...] that appears to the right of that box you just selected EVENT PROCEDURE) and enter
Code:
Me.TypeYourActualListBoxNameHere.Requery
And, just as an FYI, the key word ME is a shortcut in code that refers to the current form that you are on, so in the event for the list box it refers to the form that the list box is on.
ok i have to boxes
the first one is a combobox where i have some plants like LGN, UREA etc
and the other one is a listbox where i have some equipments and their descriptions of each one. i want that when i select LGN on the combobox the listbox have to show the equitments and the descriptions that belongs to that plant and when you select urea on the same combobox the listbox will show the equipments and descriptions of that plant
Not sure where you are using that SQL statement because if you build the query using the QBE it is actually easier as it puts the correct thing in there if you put your mouse in the criteria area of the field you want and then click on the Expression Builder, navigate to your form and then the control and doubleclick and it puts it in there. But, if you are building the SQL statement yourself in the SQL window change it to:
Code:
SELECT Qry_Delivered.[Cylinder Number], Qry_Delivered.[Cylinder Barcode Label] FROM Qry_Delivered = Forms!Qry_Delivered1.Person;
I also managed to get this working in my database. however, it only works on an individual form. when i try to incorporate the form with this function as a subform of another form, it no longer works. what adjustments do i need to make?
thanks, but im not sure if my question is being answered, or maybe i don't know my question lol. let me try to clarify; when I open up my individual form (the form being my 'Contracts' form) with this function, everything from the query posted here works; selecting a person's a name from a combo box successfully populates a list box meant to display their phone numbers.
however, when I try to open a form with this 'Contracts' form as a subform (which I had previously setup), the system now prompts me to enter in a parameter for my list box (which refers to the combo box where I select names). Does this help at all? Thanks in advance for your time, I really appreciate it.