Combo Box Searches

Clownfish1980m

Clownfish8182m
Local time
Today, 06:56
Joined
Sep 18, 2009
Messages
40
I have a database that will be used to look up medications. The user will select the drug from a combo box and then select the search button which opens a form showing the drug information. Once they have read the information they would then click on “Return to Medication Search” button which takes them back to the search screen. At the present time it shows the last drug they selected but I want the combo box to be blank and the curser in the combo box ready for the user to type another drug. Is this possible? Thanks Ken
 
In the close event of the form that will be closed, put

Forms!YourFirstFormNameHere.YourComboBoxNameHere = Null
Forms!YourFirstFormNameHere.YourComboBoxNameHere.Dropdown
 
Here is the code I added:

Forms!Search2.Combo1 = Null
Forms!Search2.Combo1.D ropdown

Search2 is the form with the combo box used to search for the medication.
When I hit the search button it goes to a form called Main Query. I put the coding on the Search2 form but nothing happens. Ken
 
Here is the code I added:

Forms!Search2.Combo1 = Null
Forms!Search2.Combo1.D ropdown

Search2 is the form with the combo box used to search for the medication.
When I hit the search button it goes to a form called Main Query. I put the coding on the Search2 form but nothing happens. Ken

It doesn't go on the search form. It goes in the CLOSE event of the form which opened to show them the medication info.
 
Correct that is where it is at:

Private Sub Form_Close()
Forms!Search2.Combo1 = Null
Forms!Search2.Combo1.D ropdown
End Sub

This is on the "Main Query" form which shows the medications information. Ken
 
Do you happen to have a subform (even if the main form is unbound) on the Search2 form?
 
The design of the form is just a combo box that is linked to a medication query. Once the user selects the medication they hit a search button which is a command button that opens the Main Query form to display the specifics of the medication. The button was programmed using the wizard to open the form based on the selection made in the combo box. Ken
 
That lockes it up and the Return to Medications Search button no longer works.
 
Okay, can you post a copy of the database with bogus data so we can take a look?
 
I have condensed down the file and eliminated a lot of irrelevent data.

Doesn't look like it attached. When selecting the file, make sure that it is under 2Mb (do a COMPACT AND REPAIR and then zip the file) and that you clicked the UPLOAD button. If it uploads successfully you will see a link appear below the text box that had the file path and name after you browsed to it.
 
Here is your fixed copy back.

1. The search combo should not be bound to the medications field, in fact there really is no reason to have the search form bound to the Medications Main Table.

2. You didn't give us the correct name of the form, so the code would not work, of course. The name of the form which needs to have the combo cleared is SEARCH, Not Search2. The CAPTION says Search2 but the name of it is Search.

3. I changed it a bit as we don't need the drop down and you should have the combo set to LIMIT TO LIST so that people can start typing and it will auto expand to the one they want.
 

Attachments

Thanks that works great. I will go and program that into the original database. Thansk so much.
 

Users who are viewing this thread

Back
Top Bottom