Combo Box on Form

mdg

Registered User.
Local time
Yesterday, 18:24
Joined
Feb 17, 2011
Messages
68
Anyone know about combo boxes? I have a form based upon a query from a large table. The form displays a certain number of records based upon a button I selected on another form with specific criteria of one or more fieldss. I would like to be able to show and select from the combo box just the records that were filtered in the query for that form. RIght now, my combo box shows all the records in the table instead of just the few that I want to have showing.
 
Did you use the wizard when you placed the combo box? Usually if you use the "find records on my form" option when using the wizard it should get it's data from the form's data.
 
Did you use the wizard when you placed the combo box? Usually if you use the "find records on my form" option when using the wizard it should get it's data from the form's data.

Thank You DBROWN. I did use the wizard and it should query should filter only the records in the form. When I click on the combo box, all the records are displayed from the orignal query. However, I can only select the records from the form. I would like the combo box to 'show' just the records the form has.
 
Did you go into the "row source" for the combo box and set that query the same as the form's query?
 
Did you go into the "row source" for the combo box and set that query the same as the form's query?

The row source shows my selection when I created the combo box: SELECT [qryMaritimeCos].[NameofCompany], [qryMaritimeCos].[id], [qryMaritimeCos].[REC] FROM qryMaritimeCos;

Also, the forms filter is set as such: [qryMaritimeCos].[REC]="BAL"
[REC]is the field that is filtered when the form opens. Right now there are just a few records in it. The combo box shows all the records but only allows me to select the ones from the form.
 
Try replacing the sql statement from the combo's row source with this:

SELECT [qryMaritimeCos].[NameofCompany], [qryMaritimeCos].[id], [qryMaritimeCos].[REC] FROM qryMaritimeCos where [qryMaritimeCos].[REC]="BAL";
 
Try replacing the sql statement from the combo's row source with this:

SELECT [qryMaritimeCos].[NameofCompany], [qryMaritimeCos].[id], [qryMaritimeCos].[REC] FROM qryMaritimeCos where [qryMaritimeCos].[REC]="BAL";

Thanks for the suggestion. However, this won't work in my situation. I have 17 different cities which I select from buttons on another form which then opens up this form and displays only the records for that city. Since it was filtered by the city, in the example above [BAL] I thought that the combo box would get filtered on the same criteria since it shows that in the proerty sheet as such. Otherwise, I will have to make 17 separate forms that display the same type of information.
 
Sorry for the late response, I had to leave work. The multiple cities should be no problem just refer back to the main form's control that contains the city you are filtering on. The blue is the form that opens the filtered form and the red is the control on that form containing the city you want it filtered on. I hope this work for you.

SELECT DISTINCT [qryMaritimeCos].[NameofCompany], [qryMaritimeCos].[id], [qryMaritimeCos].[REC] FROM qryMaritimeCos WHERE ((([qryMaritimeCos].[REC])=[Forms]![MainForm]![ControlWithCity]));
 
Sorry for the late response, I had to leave work. The multiple cities should be no problem just refer back to the main form's control that contains the city you are filtering on. The blue is the form that opens the filtered form and the red is the control on that form containing the city you want it filtered on. I hope this work for you.

SELECT DISTINCT [qryMaritimeCos].[NameofCompany], [qryMaritimeCos].[id], [qryMaritimeCos].[REC] FROM qryMaritimeCos WHERE ((([qryMaritimeCos].[REC])=[Forms]![MainForm]![ControlWithCity]));

That worked perfectly. Boy you saved my day!! I've been playing around with this thing for 2-3 days and couldn't get it quite to work right. Thr rest of my database is coming along ok and I was getting frustrated when I got to this part and amost gave up on the idea I had.
THanks a billion!!!
 

Users who are viewing this thread

Back
Top Bottom