"Larry Linson" wrote:
>
> "john@leeburn" wrote in message
> news:70CE26AC-65FC-403D-86BB-6558DF9E8EE5@microsoft.com...
> >I wish to open a form from within a sub form.
> > Main form - Contact details - ContactID
> > Subform - property details - Property ID
> > Advertising Form to Open contains PropertyID
> > If the Property form is stand alone, I can create a macro that uses
> > IsLoaded
> > and Open the Advertising form to the correct Property ID using Where
> > PropertyID=PropertyID (I have left actual detail out)
> > This doesn't work at all when the property form is a SubForm.
> > Is there a way I can get this to work?
>
> There's nothing to keep you from executing a DoCmd.OpenForm from within the
> VBA code of a Form embedded in a Subform Control. "Doesn't work" also
> doesn't give us much to go on. Neither does "leaving out the actual detail"
> because, almost certainly, "the Devil's in the details."
>
> If you really mean "Access macro" instead of VBA code, then someone else is
> going to have to pick up once you give us the details. The only macros I
> have used in recent years are AutoExec and AutoKeys.
>
> Larry Linson
> Microsoft Access MVP
>
>
>
OK thanks for replying. Here's some more detail:
I have a contacts form with a subform.
From the Marketing Options subform, I wish to open a report, but only one
record based on the OptionID within the subform. I have a control button that
runs the code below. It works when the form is open on it's own and not
imbheedded in the Contacts Form as a subform. When I use the control button
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12527
in the subform, it calls for me to enter the OptionID .. it then opens the
report with the correct data. I would prefer not to have to enter the
OptionID. So hope this is clearer ... it works just fine on its own but not
when it in the subform.
Cheers and thanks,
John
Private Sub Marketing_Click()
On Error GoTo Err_Marketing_Click
Dim stDocName As String
stDocName = "MarketingOption"
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12527
DoCmd.OpenReport stDocName, acPreview, ApplyFilter, "OptionID =
Forms![MarketingOptions]![OptionID]"
Exit_Marketing_Click:
Exit Sub
Err_Marketing_Click:
MsgBox Err.Description
Resume Exit_Marketing_Click
End Sub