1

I have created my database and my database have tabs like student name, birth date, Nationality, School, Department, Cell phone number, ID card number.

I know how to search value from this database using one "Text box" search option. I can create a text box and can also create query for that and can find out the results from the database.

But in the search form i want to use one dropdown search box. Like in the tab Nationality, all the Country will be there in the dropdown list and if i select a country from drop down list, my result will show all the student info from that country.

Microsoft access experts need your help.

user2663126
  • 101
  • 12
  • http://stackoverflow.com/questions/7680171/getting-combobox-value-in-access-vba and http://stackoverflow.com/questions/3423442/access-2007-using-the-id-value-from-a-list-box-in-vba-sql-statement should provide your answer. Depends on if your using the combo box or list box – Grant Oct 26 '13 at 12:37
  • @TKEyi60 I think the above two links that you had mentioned cannot help me. I am not getting any way out through which by using combo box my values show up in the result. – user2663126 Oct 26 '13 at 13:10
  • For a dropbox, you would either need either the combo box or list box. Then you can populate it with a table or by typing in the values. To obtain the selected value you then use `Me.Combobox.Column(n)`. Are you saying your using a different method? Or that you're trying them but it's not working? – Grant Oct 26 '13 at 14:29

1 Answers1

0

You say, 'my result will show all the student info from that country'. I don't know if that means modify the results of the forms data source or change a secondary combo box based on the selection of the first. So, below I am showing a simplified way of doing both.

Private Sub cboCountry_AfterUpdate()
  If (vba.strings.len(cboCountry.Value & "")<>0) Then
    'To change the RowSource of another combo box do the following:
    cboStudents.RowSource = "SELECT * FROM Students WHERE CountryID = " & cboCountry.Column(0)

    'To Filter the forms data source perform the following:
    Me.Filter = "CountryID = " & cboCountry.Column(0)
  Else
    Me.Filter = ""
    cboStudents.RowSource = "SELECT * FROM Students"
  End If

  Me.Refresh
End Sub
Linger
  • 14,942
  • 23
  • 52
  • 79