andyb7901
asked on
VBA - Combo Box ID
I ave a combo box, which I want to move from one form to the other. On the new form I will have a combo box listing staff members and another listing offices. I have tried to simply copy and paste the box, but it tells me that "this control has an invalid control source" But the control source works fine on the other form. I have also tried recreating the combo using the wizard, but i get the same error message. Can someone tell me why?
ASKER
The control source is the Office Id (IDOffice), its exactly the same as the other form, except it doesnt work?? It populates the combo box with names, but woant allow you to click on one or select one, or populate a name to start the box of??
Is the RecordSource the same for both forms? If not, the ConrolSource may not be available for the combo box.
ASKER
I dont know what you mean by that, im not really clued in about combo boxes??
ASKER
Ah sorry I get what you mean now, the two different forms, have two different record sources. Is there anyway to assign the actual combo box to a record source apposed to the form?
The point is you have to set the ControlSourse for your combo box to the name of the field where you want to store the selected value.
You will get a list of all the fields as a drop-down when you click into the controlsource property.
Pete
You will get a list of all the fields as a drop-down when you click into the controlsource property.
Pete
You might want to remove the ControlSource from the combo box, copy the combo box to the new form, restore the ControlSource to the original combo box, and select a new ControlSource from the drop-down box in the ControlSource property in the new combo box.
ASKER
The combo data will be from two different tables though. Will that matter? Will I not have to assign two record sources??
In that case you should scrap your current combo box in your second form and use the wizard to create one that is suitable for the form.
Pete
Pete
Set the RowSourceType property to Table/Query, select the elipses (...) button next to the RowSource property, and build your own query for the combo box.
ASKER
I kind of have it working now, but does anyone know how to put the first office in the combo box before the drop down is pressed, apposed to all being hidden until you select one, and also how to turn them all into capitals??
>how to put the first office in the combo box before the drop down is pressed
I just have the combo box drop down. Would that do it for you? If so, I can give you the code to add so that happens.
>how to turn them all into capitals
In the query you made to populate the combo box, use the Ucase() function.
For example, if your field is named "LastName" then in the top box in the query enter:
LastName: Ucase([LastName])
I just have the combo box drop down. Would that do it for you? If so, I can give you the code to add so that happens.
>how to turn them all into capitals
In the query you made to populate the combo box, use the Ucase() function.
For example, if your field is named "LastName" then in the top box in the query enter:
LastName: Ucase([LastName])
ASKER
Basically the two combos I have the first one just has the first field in combo visible in the combo before the combo is expanded. The second combo doesnt do this, so looks odd?
Im not to sure what you mean by the Ucase() function. I havent ran a query on it, i have simply called data using the wizard. All I want is for the cmobo box to be in all uppercase?
Im not to sure what you mean by the Ucase() function. I havent ran a query on it, i have simply called data using the wizard. All I want is for the cmobo box to be in all uppercase?
1. Select the ellipses (...) button next to the RowSource property of your new combo box.
2. Select the View menu => SQL View.
3. Copy the SQL statement and paste it in here so I can see your query.
2. Select the View menu => SQL View.
3. Copy the SQL statement and paste it in here so I can see your query.
ASKER
SELECT TblOffice.IDOffice, TblOffice.fldOffice
FROM TblOffice
ORDER BY TblOffice.IDOffice;
FROM TblOffice
ORDER BY TblOffice.IDOffice;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the controlsource? Is it part of the form's underlying query/table?
Pete