Referencing unbound subform error

G

Guest

Can someone point out my error to this scenario:

I have a frmMain with 2 subforms. Subform1 is in Datasheet view to enter
various trnsactions. Subform2 contain additional details for certain
Transaction type in subform1. Thus, I only need subform2 populated if the
user select Transaction type 3, for example. So, Subform2 is unbound when
frmMain loaded but I want to manual set the recordsource and master and child
link in the Subform1_AfterUpdate if TransactionType=3.

I get the error 2467 "The expression you entered refer to an object that
doesn't exist or is closed" in the Set statment.

My SetSubform2 is as followed:

Dim sSQL As String
Dim frmSub As Form

Set frmSub = Forms!frmMain.Controls("frmLOBSub").Form <--PROBLEM HERE

frmSub.LinkMasterFields = "StID"
frmSub.LinkChildFields = "StID"

sSQL = "SELECT * FROM tblEmployee WHERE [StID]='" & Me!StID & "'"

frmSub.RecordSource = sSQL
frmSub.Refresh

end sub

frmLOBSub is the name of the subform2 control on the frmMain. What is wrong?

Thanks in advance!
 
G

Guest

I think that all you need is that

Instead of this line
'Set frmSub = Forms!frmMain.Controls("frmLOBSub").Form <--PROBLEM HERE

Put
me.frmSub.sourceobject = "SubFormName"
 

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