activate combobox on opening form

Yuri

New member
Local time
Tomorrow, 00:01
Joined
Jul 18, 2011
Messages
5
Hey there,

I have an bound form with in the header an unbound combox. So, the detail section shows the results of the combox. In the from footer I put a subform. Everything works fine once you have chosen your value from the combobox (list of values).

My problem is that when I open the form it will not show the details of the default combobox value. Instead it shows all the values in the detail section. Only when you select a value from the box it will start showing the correct corresponding details.

So, what I would like to know is how to open the form with the detail section immediately showing the record details of the default value in the combobox.
I tried to put some code in an event procedure on loading the form. But I have little VBA knowledge. I tried:

Private Sub Form_Load()

Dim rst As DAO.Recordset
Dim strCriteria As String
Dim frm_fut_exp As Object

strCriteria = " [cmdChooseClass]='Strategic'"
Set rst = frm_fut_exp.RecordsetClone

With rst
.FindFirst (strCriteria)
End With

frm_fit_exp.Bookmark=rst.Bookmark

Set rst = Nothing
DoCmd.GoToControl "cmdChooseClass"

End Sub

It gives me a runtime error 91. Object variable not set. Looks straight forward, but I don't know what to change or if this really is the code to achieve a reactivation of the combobox. Or maybe there is another solution?

Thanks very much for all your help !!!
 
Hi..

Would you try this way..:

Code:
Private Sub Form_Load()
call [COLOR="Red"]combobox_name[/COLOR]_Afterupdate
End Sub

I hope you do not understand the wrong question.. ;)
 
Thanks very much Taruz !!
That did the trick. Looks so simple now :)
 

Users who are viewing this thread

Back
Top Bottom