Combo box Filter

A

Asif

Hi All, I have a form that displays three columns labelled Science,
Maths and Languages. Below each column is a command button "New
Records". Upon click the button a new form (frm_NewRecord) opens up
allowing the user to enter a new record. This form (frm_NewRecord)
contains a combobox which holds all the books. What I want to do is
when the user clicks on say New Records for the science column then
the combobox in frm_NewRecord should only display the books related
that that category likewise for the other buttons.

Any suggestions??

Thanks
 
S

storrboy

Hi All, I have a form that displays three columns labelled Science,
Maths and Languages. Below each column is a command button "New
Records". Upon click the button a new form (frm_NewRecord) opens up
allowing the user to enter a new record. This form (frm_NewRecord)
contains a combobox which holds all the books. What I want to do is
when the user clicks on say New Records for the science column then
the combobox in frm_NewRecord should only display the books related
that that category likewise for the other buttons.

Any suggestions??

Thanks


In the command button, use the OpenArgs argument of DoCmd.OpenForm to
pass an indicator of what column is desired. In the new record form's
Open event set the combobox rowsource based on the OpenArgs value.
Example in the open event...

Secelect Case Me.OpenArgs
Case "Science"
Me![ComboName].RowSource = "Select * From TableScience;"
Case "Math"
Me![ComboName].RowSource = "Select * From TableMath;"
Case "Languages"
Me![ComboName].RowSource = "Select * From TableLanguages;"
End Select

Me![ComboName].Requery

Replace control names and appropriate queries as needed.
 

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