Can't change recourdsource in subform

  • Thread starter Thread starter swas
  • Start date Start date
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
 
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.
 
I think you have to call a subform as control on the mainform

Try

Forms![YourMainForm]!frmVarianceDetail........
 
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
 
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
 
Back
Top