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

Setting a value in a subform

P: n/a
I have a form that has a subform that has a subform.

The subform loads a record based on a combo lookup box in the main form.
I'm trying to set a value in the subform based on a value in a subform of
the subform.

the main Form is called [Clock Out]
Subform is called [Clock Out Subform]
Subform in the subform is called [Pay IOU Subform]

The proceedure i am running is from the On Dirty event proceedure in the
[Pay IOU Subform] .

I am trying to set a value for the text box named [txtIOUAmountPaid] in the
[Clock Out Subform]

I can copy the [txtIOUAmountPaid] text box to the [Clock Out] main form and
set the value there using:

Forms("Clock Out")("txtIOUAmountPaid").Value = 64 'Note:Using 64
to test it.

in the on dirty event proceedure which runs when there is a change in the
[Pay IOU Subform].

however, I am unable to set the value if the control is in the [Clock Out
Subform].
For some reason I can't find the [Clock Out Subform]
I've typed this in the immediate window to see if the forms exist.
? CurrentProject.AllForms("Clock Out Subform").IsLoaded
False.
? CurrentProject.AllForms("Clock Out").IsLoaded
True
? CurrentProject.AllForms("Pay IOU Subform").IsLoaded
False
I am assuming that I can't set the value becuase the subforms don't appear
to be loaded. But they should be. I can set other values in the subform if
I type them in and they are saved with the record. Why are the subforms not
showing up with the isloaded call.
How can I set a control in a subform. I have tried 30 or so different
combinations with dots & exclamation points with no luck.

Any help appreciated
thanks
john michael

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
When a form is a subform, it is not part of the Forms collection, so you
can't reference it that way. You'll need to use the syntax:

Forms!Main_Form_Name!Subform_Control_Name.Form!Con trolName
(there is a shortened version of this, but this is less prone to
misunderstanding IMHO).

So if your Clock Out Subform is in a control called sfClockOut, you would
use:
Forms![Clock Out]!sfClockOut.Form!txtIOUAmountPaid
or
Forms("Clock Out")("sfClockOut").Form("txtIOUAmountPaid")

short form:
Forms("Clock Out")("sfClockOut")("txtIOUAmountPaid")

--
Shane Suebsahakarn
----
Head of IT
PAN Telecom
Tel: +44 (0) 870 757 7001

"John Michael" <jo***@acadiacom.net> wrote in message
news:10*************@corp.supernews.com...
I have a form that has a subform that has a subform.

The subform loads a record based on a combo lookup box in the main form.
I'm trying to set a value in the subform based on a value in a subform of
the subform.

the main Form is called [Clock Out]
Subform is called [Clock Out Subform]
Subform in the subform is called [Pay IOU Subform]

The proceedure i am running is from the On Dirty event proceedure in the
[Pay IOU Subform] .

I am trying to set a value for the text box named [txtIOUAmountPaid] in the [Clock Out Subform]

I can copy the [txtIOUAmountPaid] text box to the [Clock Out] main form and set the value there using:

Forms("Clock Out")("txtIOUAmountPaid").Value = 64 'Note:Using 64 to test it.

in the on dirty event proceedure which runs when there is a change in the
[Pay IOU Subform].

however, I am unable to set the value if the control is in the [Clock Out
Subform].
For some reason I can't find the [Clock Out Subform]
I've typed this in the immediate window to see if the forms exist.
? CurrentProject.AllForms("Clock Out Subform").IsLoaded
False.
? CurrentProject.AllForms("Clock Out").IsLoaded
True
? CurrentProject.AllForms("Pay IOU Subform").IsLoaded
False
I am assuming that I can't set the value becuase the subforms don't appear
to be loaded. But they should be. I can set other values in the subform if I type them in and they are saved with the record. Why are the subforms not showing up with the isloaded call.
How can I set a control in a subform. I have tried 30 or so different
combinations with dots & exclamation points with no luck.

Any help appreciated
thanks
john michael



Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.