Button on main form to simulate clicking of a hyperlink field on the subform

  • Thread starter Thread starter Russ via AccessMonster.com
  • Start date Start date
R

Russ via AccessMonster.com

Help,
Need a button on main form to simulate clicking of a hyperlink field on the
subform
Button name is open the hyperlink field is FilenamePath
Any ideas on how to do this?
Thanks
 
Something like:

Private Sub cmdHyperlink_Click()

Application.FollowHyperlink Me!MySubformContainer.Form!MyTextbox

End Sub


Note that MySubformContainer in the expression above refers to the name of
the control on the main form that contains the subform. That name may or may
not be the same as the name of the form being used as a subform: it all
depends on how you added the subform to the main form. If you dragged a form
onto the main form, then the two names should be the same. If you chose the
subform control from the toolbox and added the control to your main form
(whether or not you used the wizard to add the subform), the subform
container name will be something like Child0.

If you're trying to open a file (as opposed to a URL), you can check that
the file exists first before using the FollowHyperlink method as:

Private Sub cmdHyperlink_Click()

If Len(Dir(Me!MySubformContainer.Form!MyTextbox)) > 0 Then
Application.FollowHyperlink Me!MySubformContainer.Form!MyTextbox
End If

End Sub
 
Douglas, that did the trick and worked great.
Thanks for the help!

Something like:

Private Sub cmdHyperlink_Click()

Application.FollowHyperlink Me!MySubformContainer.Form!MyTextbox

End Sub

Note that MySubformContainer in the expression above refers to the name of
the control on the main form that contains the subform. That name may or may
not be the same as the name of the form being used as a subform: it all
depends on how you added the subform to the main form. If you dragged a form
onto the main form, then the two names should be the same. If you chose the
subform control from the toolbox and added the control to your main form
(whether or not you used the wizard to add the subform), the subform
container name will be something like Child0.

If you're trying to open a file (as opposed to a URL), you can check that
the file exists first before using the FollowHyperlink method as:

Private Sub cmdHyperlink_Click()

If Len(Dir(Me!MySubformContainer.Form!MyTextbox)) > 0 Then
Application.FollowHyperlink Me!MySubformContainer.Form!MyTextbox
End If

End Sub
Help,
Need a button on main form to simulate clicking of a hyperlink field on
[quoted text clipped - 3 lines]
Any ideas on how to do this?
Thanks
 
Back
Top