Insert a form into a subform (1 Viewer)

RicksBoat

New member
Local time
Today, 01:22
Joined
Dec 15, 2018
Messages
4
Hello,
I currently have a form that presents options to a user. Based on those options a subform is opened. I would like to present that subform (insert it if you will) into a subform (DM) in that original form. I want to present the data like this as there are many possible combinations of the output data.

I am developing a conditional statement and trying to insert the subform by adding the following to the code.

If This = "stuff1" And That = "Stuff2" Then
DoCmd.OpenForm "output1"
Set dbs = CurrentDb
dbs.Execute " INSERT into DM " _

It will not insert the subform into "DM"
I am missing something or do I need to go in a different direction with this?
Thank you for any advice you may have.

Rick
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:22
Joined
Oct 29, 2018
Messages
21,467
Hi Rick. Is "DM" the name of a subform? If so, the INSERT statement is only used to insert data into tables. For dynamic displays of subforms, you can can add an empty subform container to a form and simply assign an appropriate form name to its SourceObject property using code.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:22
Joined
May 7, 2009
Messages
19,233
agree with theDBguy.
Code:
If This = "stuff1" And That = "Stuff2" Then
    [DM].SourceObject = "Form.theFormToShowHere"

ElseIf This = "stuff3" And That = "Stuff4" Then
    [DM].SourceObject = "Form.theOtherFormHere"
End If
 

RicksBoat

New member
Local time
Today, 01:22
Joined
Dec 15, 2018
Messages
4
Hi, "DM" is the name of the subform. Thank you for the INSERT information...There is so much I am learning. I will let you know how I make out revising the code layout as provided by arnelgp as soon as I can get to it. My wife just threw out her back and needs minor attention.
Thank you again
Rick
 

Users who are viewing this thread

Top Bottom