Adding item in listbox

G

Guest

Hi,

I am new to coding in MS Access.. I would like to display different values
in a listbox depending upon the selection i make in a combo box..
fir example if i select Region 2 in combo box it should display US, Brazil
ec..
I have done the same in excel vba, using
listbox2.additem but i unable to use that object in msaccess..
can you pls help me...

thanks, srikanthan.
 
S

Stefan Hoffmann

hi,
I am new to coding in MS Access.. I would like to display different values
in a listbox depending upon the selection i make in a combo box..
fir example if i select Region 2 in combo box it should display US, Brazil
ec..
I have done the same in excel vba, using
listbox2.additem but i unable to use that object in msaccess..
can you pls help me...
This is not done with code in Access. You need at least one table:

Country: ID, Region, CountryName


The row source of your ComboBox, called cmbRegion:

SELECT DISTINCT Region FROM Country

The row source of your ListBox, called lstCountry:
SELECT Country FROM Country WHERE Region = Forms!YourForm!cmbRegion

Place a lstCountry.Requery in the change event of cmbRegion.


mfG
--> stefan <--
 
D

Douglas J. Steele

Stefan Hoffmann said:
hi,

This is not done with code in Access. You need at least one table:

Actually, it can be done in Access, but only Access 2002 or newer. Make sure
the RowSourceType property of the combo box is set to "Value List"

Havine said that, though, I'd agree it's superior to base it on a table.
 
G

Guest

Hi Stefan,

Thanks for your explanation.. I could do the steps you have mentioned
below.. I have created two queries cmbRegion and lstcountry as given below,
but when i place lstcountry.requery in the change event of combo box, it is
showing an error as
Runtime error : Object required..
How do i place lstcountry.requery in change event of cmbRegion?.
Appreciate your help in this..

Thanks much
 
S

Stefan Hoffmann

hi,
Thanks for your explanation.. I could do the steps you have mentioned
below.. I have created two queries cmbRegion and lstcountry as given below,
but when i place lstcountry.requery in the change event of combo box, it is
showing an error as
Runtime error : Object required..
Maybe it wasn't that clear.
How do i place lstcountry.requery in change event of cmbRegion?.
lstCountry and cmdRegion are the controls on your form. The SQL
statements have to be pasted in their RowSource property.


mfG
--> stefan <--
 
G

Guest

Stefan,

I got it right now.. thanks a lot for explaining.. i misunderstood
previously.. thanks very much..
 

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