subform recordsource change

CJBIRKIN

Drink!
Local time
Today, 14:06
Joined
May 10, 2002
Messages
256
Hi

For reasons best left unsaid i am trying to change the recordsource of an unbound subform from a button on another unbound subform.


mainform = Frm_Frames
Subform = FRM_AUDIT_MENU subform called FRAME_1
Subform = FRM_SELECT_AUDIT subform called FRAME_2


Simply, i collect an SQL string from controls on Frame_1 and use it to create the recordsource for Frame_2.

I have been able to do this when doing this with a mainform/subform.

Me.Form!FRAME_2.Form.RecordSource = StrRecSource


But i don't seem to be able to do it from Frame_1, i expected something like

Form_Frm_Frames.Form!FRAME_2.Form.RecordSource = StrRecSource

But i get the error "You entered an expression that has an invalid reference to the property form/report"



Any clues

Cheers

Chris
 
I'm guessing it's because you are not referencing the forms collection properly? I do this in a couple of my db's, and I'm sure it is something along the lines of:

Forms!Frm_Frames!Frame_2.Form.RecordSource = StrRecSource

HTH.
 
Matts' suggestion is OK, but you can also refer to the parent of the subform where you run the code from (FRAME_1):
Code:
Me.Parent!Frame_2.Form.Recordsource = strRecSource
 
Hi

I tried both methods and came back with identical error messages as i had.

I don't understand how this can be.

Have you any other ideas?? I'm stumped.

Cheers

Chris
 
FUDGE

Hi

I got round the problem with a fudge.

I passed the SQL string to a private variable at module level using a set function, then i call the data on the form load event of FRM_SELECT_AUDIT (frame_2) with a get function.

The problem is i have search facilities on the FRM_AUDIT_MENU (frame_1) that i am using to to create the SQL string.

So i tried to find an event that was activated on FRM_SELECT_AUDIT (frame_2) when it is requeried, and i couldn't .

So i am now loading an interim form into frame_2 ( can't have a subform with no source object) when the SQL string is complete and then loading FRM_AUDIT_MENU back again to trigger the form load event and update the recordsource. phew!

It works but it seems to be Bull**** to me!

If anyone knows the answer to this i would be very greatful to hear from you.

Cheers

Chris
 
Hi

found the answer. The frame_1 was loading before frame_2 creating the errors, DOH!

so i forced the frames to load their (sourceobject) forms in reverse and then used.

Forms("FRM_FRAMES")!FRAME_2.Form.RecordSource = StrRecSource.

on the onload event of the form in frame_1 and no more errors!!!




Chris
 

Users who are viewing this thread

Back
Top Bottom