View Full Version : Subform with a list.


bishop_13298c
10-10-2000, 01:46 PM
I have been trying to solve this problem for a few days and I think I have narrowed it down, but I can't seem to generate the needed code. This is the problem.

I have a main form that references one table, and it has a sub-form associated with it. The link between this form and the sub-form is an independent CustomerID. This Customer Id is not the key but each record will have a different value. The sub-form has a list-box that displays all records from another table, independent from the main form. My problem is that when the main form opens it does not shown the sub form when the list-box is included. When the sub-form does not include the list-box everything works fine. The list-box uses this CustomerID to generate the list. I believe that this list box tries to call the CustomerID before it is available to the sub-form, and so it returns an error.

The other thing that is just one added problem, is that I would like to keep it as generic as possible. This sub-form is going to be referenced by several main forms. These forms will have similar properties, but filter records differently.

Does any one know of a way that I can force the list box to wait for the CustomerID. I believe that this will solve the problem. If you can think of a better way of handling it, that works for me too.

Thanks in advance.

Pat Hartman
10-10-2000, 04:15 PM
As you may have figured out by now, the sub-form's Load and Open events fire before the main form's Load and Open events. And, this is causing the problem. Rather than using a subform, how about using an independent form that you open when a value is placed in the CustomerID field of the main form?

bishop_13298c
10-11-2000, 10:55 AM
Pat,

Thanks for the reply. I started to add another form like you suggested, but I could not afford the real estate. Your idea gave me another idea. For any one the runs into a similar problem, I took the list out of the subform. I then wrote a query for the list to follow keying off of the CUST_ACCT_ID. I then added a refresh query statement to Form_Current() for when the record is changed. Everything works great. Thanks for your help.