selecting combo row in VBA

D

dave h

I feel like this is a really dumb question, but its driving me nuts....
I have a form that contains a combo box that syncs the rest of the controls
on the form to the row selected in the combo box - works great. However, I
need to call another (child) form that adds new rows to the table underlying
the combo box on the parent form. Once the table is updated with a new row,
the child form is closed, the combo box on the parent form is requeried and
control is returned to the parent form. So far, all is well and the new row
is in the parent form combo box. Although that new row can be selected
manually, I really want to select the row in my code before I leave the
child form so that the parent form displays all the synchronized data in its
controls - embarrassing to ask the user to do this manually.

I cannot figure out how to set the selected row in that combo box. This
seems like combo box 101, but I just can't find the right property to set to
make this happen in my VBA code.

Thanks, Dave H
 
S

Sandra Daigle

Hi Dave,

When you have the key value for the new row (whatever field you are using as
the bound field of the combo) just assign that value to the combo.

me.cboPickCustid = lngNewCustid
 
D

dave h

Hi Sandra,

Thanks for the respones - that was the one thing I didn't try!

For anyone else interested in this thread, I also set the focus and redid
the code associated with the combo box after-update event to sync the rest
of the controls on the form with the row selected in the combo box.

Thanks again.

Sandra Daigle said:
Hi Dave,

When you have the key value for the new row (whatever field you are using as
the bound field of the combo) just assign that value to the combo.

me.cboPickCustid = lngNewCustid

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


dave said:
I feel like this is a really dumb question, but its driving me
nuts....
I have a form that contains a combo box that syncs the rest of the
controls on the form to the row selected in the combo box - works
great. However, I need to call another (child) form that adds new
rows to the table underlying the combo box on the parent form. Once
the table is updated with a new row, the child form is closed, the
combo box on the parent form is requeried and control is returned to
the parent form. So far, all is well and the new row is in the
parent form combo box. Although that new row can be selected
manually, I really want to select the row in my code before I leave
the child form so that the parent form displays all the synchronized
data in its controls - embarrassing to ask the user to do this
manually.

I cannot figure out how to set the selected row in that combo box.
This seems like combo box 101, but I just can't find the right
property to set to make this happen in my VBA code.

Thanks, Dave H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top