Close combobox after selection

Autoeng

Why me?
Local time
Today, 18:13
Joined
Aug 13, 2002
Messages
1,302
I have a combobox on a form that takes a long time to populate when first selected so I coded the combobox's On Got Focus event to include

Code:
Me.MyComboBox.Dropdown

This works great but after selecting a record the combobox does not close even though the form fills appropriately. I have to click onto another field before the combobox will close.

What am I missing?
 
Maybe..
Code:
Me.AnotherControl.SetFocus
HTH
 
Ok I'll try that. How do I set focus to a field on a subform?

Code:
Forms![frmSubForm].[SubFormfield].SetFocus

Yes?
 
I think it'll be..
Code:
Forms![YourFormName]![YourSubform]![SubformField].SetFocus
HTH
 
Like so?...

Code:
Forms![MySybFrm].SetFocus
Me.MySubFrmField.SetFocus

What event would be best? I was thinking in the After Update of the combobox as the combobox never really loses focus.
 
You can only use Me.MyField if the combo is on the subform, otherwise you'll have to use the full forms reference
 
Is there some other code affecting the combo? Mine auto returns after selection or tabbing to another field, you'll have to try the AfterUpdate to see if it works, I've no way of testing it:(
 
Here is the code I placed in the After Update Event of the combobox.

Code:
Forms![frmVCBsf2].SetFocus
Forms![frmVCBsf2]![DueDateConfirmed].SetFocus

I am getting the error that "Cannot find form frmVCBsf2". Name is correct .

I tried to clairify the from first but still no luck
Code:
Forms![frmVCB]![frmVCBsf2].SetFocus
Forms![frmVCBsf2]![DueDateConfirmed].SetFocus

Anybody see what I am missing?
 
It's the name of the subform control as it appears on the property sheet you need, not as it appears in the db window
 
Just got it.

Code:
Forms![frmVCB]![frmVCBsf2].SetFocus
Forms![frmVCB]![frmVCBsf2]![DueDateConfirmed].SetFocus

For whatever reason I had to refer to the mainform in both lines.
 

Users who are viewing this thread

Back
Top Bottom