1
votes

I have a form with a combo box in the form header that populates the values in the form. I can select different values in the combo box that refer to observations in my table, and the form will filter so that I have all the data from the table for the observation I select in the combo box in the form.

It works fine, however when I open the form, the form is populated with the first row in the table, even though the combobox is blank. How do I set up the form so that when the combobox in the header is blank then the form is blank, and the form only populates when I populate the combobox?

Thanks

2
By the sounds of it you are just changing records based on the selected Combobox option. When you open a form however it is automatically going to be viewing the first record. Not entirely sure if that can be changed easily, but perhaps instead of fighting it you just make it so that the combobox reflects the proper name of the observation? - Newd

2 Answers

1
votes

You could leave the subform Record Source blank and in the combo box AfterUpdate() event, change the subform Record Source and Requery the subform.

This can be a bit sloppy since form requeries are notorious for their unreliability. What I've done in the past is make the subform a PopUp and in AfterUpdate() of the combo box or on a button click, modify the Record Source and open the desired subform.

0
votes

As I had mentioned in my comment I think what you are trying to do could be fairly annoying to implement. However if you just add something like this:

Private Sub Form_Load()
    Me.Combobox1.Value = Nz(Me.ObservationName,"")
End Sub

It would just make the Comboboxreflect the proper name of the observation that you are viewing. ObservationName is just what I assume is the field name that you use in the Combobox, and Combobox1 would be replaced with the name of your Combobox.