Changing subform to subreport via VBA (1 Viewer)

gunslingor

Registered User.
Local time
Today, 14:35
Joined
Jan 13, 2009
Messages
50
Okay!~

My main form just has a couple of buttons off to the left and a subform/subreport window filling up the rest of the screen. When you click a button, it changes the subform/report record source (i.e. my main form acks like a shortcut bar or, in html, a frame window). Everything works great except when I try to change the source object to a report object. Here is the code:

Option Compare Database
Private Sub Command0_Click()
Me.Child3.SourceObject = "frm_parse_all"
End Sub
Private Sub Command1_Click()
Me.Child3.SourceObject = "frm_Boxes"
End Sub
Private Sub Command2_Click()
Me.Child3.SourceObject = "frm_Boxes_by_plant"
End Sub
Private Sub Command8_Click()
Me.Child3.SourceObject = "rpt_Complete"
End Sub

Private Sub Form_Load()
Me.Child3.SourceObject = "frm_Boxes"
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Child3.SourceObject = "frm_Boxes"
End Sub

The error I get is strange:
"Run-time error '3011':
The Microsoft Jet database engine could not find the object '~sq_cMain_Shorts~sq_cChild3'. Make sure the object exists and that you spell its name and path correctly."

My main form ("Me") is called "Main_Shorts" and the single subform/report is called "Child3". But I have no idea how or why the text got parsed as it did in the error message

Any suggestions? Do I have to change the SourceObject of forms and reports differently? And why?
 

SOS

Registered Lunatic
Local time
Today, 14:35
Joined
Aug 27, 2008
Messages
3,517
Well, for one you can't put a sub report on a form. You can put a sub form on a form and a sub report on a report but you need the right thing for the right object.
 

gunslingor

Registered User.
Local time
Today, 14:35
Joined
Jan 13, 2009
Messages
50
Well, for one you can't put a sub report on a form. You can put a sub form on a form and a sub report on a report but you need the right thing for the right object.

SHMEG HEAD!

Nice to see another Red Dwarf fan out there, on the information super highway.

Anyway, That sucks. Access has zero flexibility.
 

Users who are viewing this thread

Top Bottom