Mar 15 2005, 12:07 PM
I have a combo box on a form that when I open the form I want to have that combo box displaying a value I send from the previous form.
BoxList has 4 values from a query (a, b, c, and d). When I open the for with BoxList it shows blank and then I can choose from the drop down.
The previous form can pass a value (a, b, c, or d). Using this value I want BoxList to display that row when I open the form. I still want to be able to choose another value from the drop down if the users wants to change it.
Note: The query behind the combo box uses 2 columns, an ID column and a Description column. I want to be able to pass the ID from the previous form.
Also note, the previous form may pass a null value as the ID if the user is setting the value for the first time.
I hope this makes sense.
Mar 15 2005, 12:13 PM
You can utilise the OpenArgs method of the DoCmd.OpenForm command to pass the ID value from one form to the other, then in the OnLoad event of the form, use code to determine if the OpenArgs variable contains a value, if it does, set the combo box to that value using something like:
ComboBox1 = Me.OpenArgs
or just don't do anything.
Mar 15 2005, 12:36 PM
Try placing this code in the on open event of form the form with the combo box.
Me.cboPassValue.Value = Forms!Form2.Form.ID.Value
You would just reference the ID value on the form that you're opening it up from, so it would display that record in the combo box. All the other records would be in the combo box too. Hope this helps.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here