Syntax for Refreshing Control on Sub-Subform

J

Jaybird

I'm close, but get no cigar... Can anybody please tell me the proper syntax
for refreshing or requerying a combobox on a subform that is embedded within
another subform from another subform on the mainform? I'm trying to set it
up (in the AfterUpdate event property of the Chrgs field on Subform1) so that
changes made to the Chrgs field on subform1 causes the cboLineItems combobox
on Sub-Subform2 to be refreshed or requeried, so that a calculated textbox on
the same sub-subform can be recalculated?

I know that's a mouthful... If you need further clarification, I will
describe my setup in further detail: I have a main form with two subforms.
Subform1 has a textbox on it (textbox [Chrgs]) that must sometimes be
updated. I would like the AfterUpdate control of this textbox to trigger a
refresh or requery of a combobox on a subform that is embedded within the
second subform (Subform2) on my main form. I call this embedded subform
Sub-Subform2. The combobox on Sub-Subform2 is called KEYNUM. Once this
combobox is requeried, I need a calculated text box (also on Sub-Subform2) to
be recalculated so that changes to my Chrgs textbox on Subform1 will be
reflected in the Line Totals calculations that take place on Sub-Suform2.

My code is currently this:

Private Sub ChrgPartNumber_AfterUpdate()
Me.Parent!sbfHDRPLAT.Form!sbfLINPLAT.Form.Dirty = False
Me.Parent!sbfHDRPLAT.Form!sbfLINPLAT.Form!KEYNUM.Recalc

But I get a "Object doesn't support this property or method (Error 438)"
message.

Help will be greatly appreciated!

End Sub
 
T

tina

if i understood correctly, you have

Main form
Subform1 in main form
Subform2 in main form
Subsubform2 in Subform2
Combobox in Subsubform2

and you want to recalc the control in Subsubform2, from within Subform1.
replacing these names with the correct names in your db, try

Me.Parent!Subform2.Form!Subsubform2.Form!Combobox.Requery

remember that each subform must be referred to by the name of the
"container" control within the parent form that "holds" the subform, NOT by
the name of the subform as it shows in the database window. depending on how
the subform was added to the parent form, these two names may be the same,
or they may be different.

hth
 
J

Jaybird

Bless you, Tina, for answering questions on a Saturday! However, I'm still
getting the error 438. I realize now that in posting my question, I tried to
make things clear by simplifying the form and control names, but then muddied
it all up again by posting the actual code with the actual names. In any
case, my syntax looks correct. These two line seem to match up:

Me.Parent!sbfHDRPLAT.Form!sbfLINPLAT.Form!KEYNUM.Requery (mine)
Me.Parent!Subform2.Form!Subsubform2.Form!ComboBox.Requery (yours)

I'm now thinking that perhaps giving my subforms and subform controls the
same name was a mistake and is causing the problem. Could this be it?
 
T

tina

well, i suppose it's possible, though i've never heard of it being an issue
(not that my ear's to the ground 24x7! <g>). i can't say from experience
because i always give the subform "container" control a unique name, usually
beginning with Child, as

ChildPayments

or whatever is short and descriptive of the subform records.

are you getting the 438 error on the Requery line of code, or on the Dirty =
False line of code directly above it? this could also be a sticky little
issue with placement of the code; you could try moving the code to the
form's (Subform1) AfterUpdate event procedure, rather than the control's
AfterUpdate. if you're still having no luck, and after verifying the names
of all objects as correct in the code, try doing an outside reference, as

Forms!MainFormName!sbfHDRPLAT.Form!sbfLINPLAT.Form!KEYNUM.Requery

instead of using the child to parent reference.

hth
 
J

Jaybird

Well, I've renamed my subform controls (all three) and fixed (I think) all
the associated coding problems associated with that little stroke of genius,
but the Error 438 problem still remains. To answer your earlier question,
the code pukes on the requery line. One thing that I did was to rename the
combobox on sbfLINPLAT (nowChildsbfLINPLAT) cboKEYNUM, but I'm getting the
same results.
 
J

Jaybird

Tina, thanks for all your help... I've got it working now. I put this code
in the AfterUpdate event of my textbox txtChrgPartNumber:

Private Sub ChrgPartNumber_AfterUpdate()
If Me.Parent.Form.ChildsbfHDRPLAT.Form.ChildsbfLINPLAT.Form.cboKEYNUM =
"LINEITEM" Then
Forms.frmInvoice.Form.ChildsbfHDRPLAT.Form.ChildsbfLINPLAT.Form.txtLINETOTL
= Me.ChrgPartNumbe
Forms.frmInvoice.Form.ChildsbfHDRPLAT.Form.ChildsbfLINPLAT.Form.cboKEYNUM.Requery
End If
End Sub

I don't know how elegant a solution it is... I always feel like I'm using
duct tape on a water pipe if I can't get something to work like I think it
should, but find something that does what I want. I just can't get that
stupid combobox to requery! Or maybe it is, but not having the results I
would expect... Anyhow, this does what I want, I think. Thanks again for
hanging in there with me!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top