Input from Subform1 to Subform2

WindSailor

Registered User.
Local time
Yesterday, 22:33
Joined
Oct 29, 2003
Messages
239
I have a main form in which I have 2 subforms in tabulated form on it.
The subforms are all of off the same table through 2 different queries, pulling at least one piece of data from the previous subform and then applying it to that particular subform.

Main table
“Name” “W value” “X value” “Y value” “Z value”

Sub1
“Name” “W value” “X value”

Sub2
"Name" "X value" "Y value"

I have a combo box on the main form which is linked to all of the subforms and sorts accordingly, and the “W”, “X”, “Y” values on the subforms are to be listed ascending. This works great.

The problem that I am having is when I change an “X value” in Sub1 to have a greater value than 0, the newly listed item that now should be displayed in Sub2 is not shown, also the values that did change, were not correctly sorted (Sub2, criteria for “X value” has to be >0 and it is to sorted ascending; otherwise it would list unwanted items). The only way I can get Sub2 to correctly list the items is to close and reopen the main form.

The multiple subforms are required because of the extra data pulled from the query(s) to make an adequate decision on the input option.

I have tried on the AfterUpdate event of “X value” on the main Sub1 form to insert or use…
Forms!MainFormName!SubFormName.Form.Requery
But oddly enough I can’t seem to get the MainFormName correct or it will not recognize it. I have more than one form built off the main table (maybe it is naming conventions now that I think of it). I have tried to requery Sub2 using the click event on the tab for that subform, but still no success ((Me.Sub2.Requery) still will not reload that subform correctly).

I have tried looking through the forum, but I just couldn’t apply what I found or I totally missed the boat.

Any input would be appreciated.

Thanks.
 
I found the solution, I made an obvious oversight.
I have one suggestion for individuals who put code into subforms etc. please put in a "breakpoint" to see if the code is running. I found that even though I used the click event on the tab for the subfrom, it wasn't an actual event; the code never fired. Learn something every day :).

The two events that I found that are valid for a subform property are; 1) Enter and 2) Exit.

The solution simply was using the Enter event and;

Private Sub YourSubFormName_Enter()
DoCmd.Requery
End Sub

From Visual Basic Help files:
DoCmd.Requery method displays any new or changed records, and removes any deleted records from the table on which the control or object is based.


Hope this helps someone.
 

Users who are viewing this thread

Back
Top Bottom