By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

How do you refer to a control on subform inside a tab control?

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.google.c om...
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

Nov 13 '05 #2

P: n/a
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.OpenRecordset(dbOpenDynaset)
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 "TabSubform1"
'on form "frmSurveyData"
'*****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*****@localhost.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.google.c om...
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

Nov 13 '05 #3

P: n/a
The Tab Control is a non-issue. Just refer to the target control as
if the Tab Control did not exist.
On 9 Sep 2004 05:48:50 -0700, jo****@ammann.com (Joshua Ammann) wrote:
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.


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.