Problem with Subform showing info before I ask it to

imayo1

New member
Local time
Yesterday, 19:25
Joined
Jun 6, 2007
Messages
4
My main form consists of an unbound combo box which lists all employees in alphabetical order, along with their id nbr. When I set up the combo box I chose the "find the records based on my table" option.

The subform is a continuous form of work performance violations .... the user can scroll down to a particular violation and click on an "Edit This" or "Delete This" to proceed further.

The problem is that when I open the form, the violations for the first person on the combo list (Let's say John Aardvark ... the list is alphabetical) appear in the subform, even though I the main form has nothing in it yet (I haven't made any selection.)

If John Aardvark has NO violations then nothing is displayed on the subform (and this is correct.)

For some reason, when the form opens it is picking up the violations for the first person on the list and putting them in the subform. I deleted the violations for "John Aardvark" and entered some violations for #2 on the list ("John Adams") and it worked correctly ... the form opened blank in the combo list and blank in the subform.

Hopefully I have made myself somewhat clear.... any help would be appreciated.... if I have to put in a "dummy" record (before Aardvark) I suppose that would work, but there's got to be something more elegant.

The parent and child link fields are the employee IDNumber (IDN) which are unique values.
 
My main form consists of an unbound combo box which lists all employees in alphabetical order, along with their id nbr. When I set up the combo box I chose the "find the records based on my table" option.

The subform is a continuous form of work performance violations .... the user can scroll down to a particular violation and click on an "Edit This" or "Delete This" to proceed further.

The problem is that when I open the form, the violations for the first person on the combo list (Let's say John Aardvark ... the list is alphabetical) appear in the subform, even though I the main form has nothing in it yet (I haven't made any selection.)

If John Aardvark has NO violations then nothing is displayed on the subform (and this is correct.)

For some reason, when the form opens it is picking up the violations for the first person on the list and putting them in the subform. I deleted the violations for "John Aardvark" and entered some violations for #2 on the list ("John Adams") and it worked correctly ... the form opened blank in the combo list and blank in the subform.

Hopefully I have made myself somewhat clear.... any help would be appreciated.... if I have to put in a "dummy" record (before Aardvark) I suppose that would work, but there's got to be something more elegant.

The parent and child link fields are the employee IDNumber (IDN) which are unique values.

The subform is probably linked to whoever is in the combobox. What you'll want to do is ensure that nothing is selected there by default. In the form_load event set the value of this combobox to null. Might also be able to set the default property as null as well but my memory is hazy on whether that'll work.
 
When a bound form is first loaded, without any other coersion it will make the first record in the recordset the current record. If you are using the field in the RecordSet as the LinkMasterField then that is why you have records in your SubForm. Assuming the *only* navigation you have on your MainForm is your ComboBox, you could set the LinkMasterField as an invisible TextBox on your MainForm that is *only* completed in the AfterUpdate event of your ComboBox. Then the only time you will have SubForm records is *after* making a selection in the ComboBox. Just my $0.02.
 
Thanks for your help -- what I ended up doing was setting the fields as Visible=False and then added a before update event (on the combo box) to make the fields visible as soon as I picked a selection from the combo box.
 
Amazing! I also have a "John Aardvark" in my test data for an app I'm building!
 

Users who are viewing this thread

Back
Top Bottom