Open Subform in a New Window using a command button

  • Thread starter Thread starter LDMueller
  • Start date Start date
L

LDMueller

I have two tables, Patents and Related. In the Patents table I have a field
called Matter and it's related to the RelatedMtr field in the Related table.

I created a form for the Patent table named frmPatents with a SubForm going
to the Related table named sfRelated. The subform automatically completes
the Matter field with the matter for the current record. This is what I want
so when I add additional matters to the related table I only have to complete
the RelatedMtr field.

I need to have the equivalent of opening the subform in a new windows. If I
try to use a command button to open the subform sfRelated it doesn't
automatically complete the Matter field with the matter for the current
record. Below is my code.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "sfRelated"
DoCmd.OpenForm stDocName, acNormal, , "RelatedMtr= '" & Me.Matter & "'"

I noticed on the Data tab of the Subformed sfRelated is as follows:
Source Object = sfRelated
Link Child Fields = RelatedMtr
Link Master Fields = Matter

I don't have this type of option using a command button to open the form
sfRelated so I'm thinking I may have to do this with code. Can anyone help
me out.

Thanks!

LDMueller
 
On Mon, 14 Jan 2008 10:35:04 -0800, LDMueller

When you open the second form, you can pass in values in the OpenArgs
argument of DoCmd.OpenForm. Then in that form's Form_Open event, you
can write 1 line of code to populate your field from the OpenArgs
value.

-Tom.
 
Back
Top