How to search record using Combo box in MS ACCESS
This blog post is going to explain how to use combo box to find a record in Access Database.
First of all you have to create a Sample database as shown in the following image.There you have to create a access table as follows
Name of the sample table is StudentInfo_Main.
Based on the above table then your next step is to create a Form according to the below image.
We are going to add combo box to this Form.Then Click on the Design Tab and Select Combo box Icon and put it on the Form interface as shown in the below image.
After you adding combo box to your form then you need to create a Query and you have to add this query as a Row Source of your combo box.Please see below image to create your query.
Once you create a query as above select the combo box and Right click and then go to the Properties,there select QrySearch as row source of the combo box.Under the property sheet select format tab and give "2" for column count.
Select the combo box and go to the Event Tab in the Property Sheet.Then Select After update as the event procedure.
Next step is to adding small VBA script part for combo box values.To do this select combo box and right click on it and select "Buil Event" then Code Editor.Befor this do not forget to change the combo box name to cboTest.Then under the combo box AfterUpdate place the followin code.
Private Sub cboTest_AfterUpdate()
'Moves to Customer Name text box and
'finds the record of whatever name is selected in the combo box
DoCmd.ShowAllRecords
Me!StudentName.SetFocus
DoCmd.FindRecord Me!cboTest
'Set value of combo box equal to an empty string
Me!cboTest.Value = ""
End Sub
Once all the steps are completed as above then time is good to check our work.so final output is as below;
Download Sample File - Please Click on the link
Once all the steps are completed as above then time is good to check our work.so final output is as below;
Download Sample File - Please Click on the link