Thanks Larry, but I guess I was not so clear in my explanation. The
control I want to set is not on the main form. It is on a page of the
tab control, beside a datasheet subform.
Here is the actual code that works on the main form's "On Current"
event. When I place it on the "After Update" event of the Qty field in
the datasheet subform, it gets to the point noted below and can't find
the controls inside the tab control.
Like I said, I've tried every reverence path I can think of and no
dice.
Any ideas? Anyone?
'Code Start
Private Sub Form_Current()
Dim qdf As QueryDef, dbs As Database, rst As Recordset
Dim iON, iOFF As Integer
iON = 0
iOFF = 0
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs(" qryCount")
'Query contains [SiteIndex], [ON-or-OFF_System] and [Qty]
Set rst = qdf.OpenRecords et(dbOpenDynase t)
rst.MoveFirst
Do While Not rst.EOF
'Check if the row in query matches the record on main form
If rst![SiteIndex] = Me![SiteIndex] Then
'Check either ON or OFF System
If rst![ON-or-OFF_System] = "ON-System" Then
'Add Qty from query to variable to count ON Sys
iON = iON + rst![Qty]
Else
'Add Qty from query to variable to count ON Sys
iOFF = iOFF + rst![Qty]
End If
End If
rst.MoveNext
Loop
'Assign the variables to unbound controls on the form
'The controls below are on "Page2" of control "TabSubform 1"
'on form "frmSurveyD ata"
'*****This is where the error occurs with AfterUpdate**** *
CountON = iON
CountOFF = iOFF
CountALL = iON + iOFF
End Sub
'Code End
Thanks,
~Joshua Ammann
"Larry Linson" <bo*****@localh ost.not> wrote in message news:<5XJ%c.52$ tJ1.37@trnddc04 >...
From code in the Form embedded in a Subform Control, to refer to a Control,
txtX, on the main (parent) Form:
Me.Parent!txtX = <the value you want to set>
For Controls on a Tab, you don't have or need a reference to the Tab Control
or Tab Page.
Larry Linson
Microsoft Access MVP
"Joshua Ammann" <jo****@ammann. com> wrote in message
news:32******** *************** ***@posting.goo gle.com... Hi,
(Using Access 2000)
I have two tables, similar to Customers and Orders. (Not an exact
parallel, but works for this example.)
On a form showing customer data, there is a tab control. One of the
tabs has a subform showing order data (in datasheet view). On the same
tab there is an unbound textbox (next to the datasheet). I placed a
command button that runs code to add the QTY from each line in the
subform and put the sum in the unbound textbox. That works, but when
you edit the QTY the total does not change until you click the button
again. I tried using AfterUpdate on the QTY field in the subform, but
an error always occurs when I try refer to the textbox.
I have tried about 9 different implicit/explicit references to the
textbox, but the procedure is just not recoginzing it.
Is it possible to refer to a control within the tab control of a form
from a subform inside the same tab control? How?!
Any help is greatly appreciated!
Thanks,
~Joshua Ammann