Can't change recourdsource in subform

S

swas

Hi,
I have a form with two subforms on it. I need to update the recordsource on
one of these subforms as it is not bound to the main form.

Me.frmVarianceDetail.Form.RecordSource = strTmp

should work. Same code on other forms works. I can change the recordsource
in the other subform (Though I don't want to - just to check). I can set a
text box on the subform to strTmp. In fact I can do anything except change
the actual recordsource.

I have recreated a form and can change it. I have recreated the subform and
same problem.

Could the problem be a corrupted parent form?

Just really frustrated in what should be something straightforward.


Thanks in advance.


swas
 
D

Douglas J. Steele

Are you certain that the name of the subform control is frmVarianceDetail?
Depending on how the form was added as a subform, the name of the subform
control may be different than the name of the form being used as a subform.
 
C

Chegu Tom

I think you have to call a subform as control on the mainform

Try

Forms![YourMainForm]!frmVarianceDetail........
 
B

BruceM via AccessMonster.com

The subform control is in the main form's Controls collection, so you can
reference it in VBA as you would any control. Me.frmVarianceDetail.Form
references the Form property of the subform control frmVarianceDetail.
However, in the Control Source of a tex boxt, or in a query, the syntax you
described is the way to go about it.

Chegu said:
I think you have to call a subform as control on the mainform

Try

Forms![YourMainForm]!frmVarianceDetail........
Hi,
I have a form with two subforms on it. I need to update the recordsource
[quoted text clipped - 19 lines]
 
S

swas

Replying to all so far...

I can place a text box on the subform and can set its text with the same, ie

Me.frmVarianceDetail.Form.txtTextBox = strTmp

I have also tried a command button on the main form with

msgbox Me.frmVarianceDetail.Form.RecordSource

to see what it is outside the vb environment (ie not stepping through code
etc...) which works.

Though I have checked the subform name (As opposed to the subform form) is
actually correct, assume the above test also confirms this. I would also
assume an error would be raised if not correct, or a compile error even. I
have alse made a new form, placed it in a new subform, and can't change it.

I thought there may be some form property setting in A2007 where
recordsource updates are dropped. ok maybe hopeful...

Corruption still seems to be a good candidate.


Thanks for the thoughts.


swas
 
S

swas

It seems the recordsource of a subform can't be updated during the
form_current event of the parent. The change is just not done, and no error
raised.

After the current event, it can be set no worries.

I just need to work out when I can set the subform recordsource now...

I don't have master / child fields set.


swas
 

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