Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Trying to open form from a hyperlink on a sub-form

I have a form that has a sub-form in datasheet view.  On the sub-form is a text field named txtRecord.  The field is a hyperlink.  When the user clicks it I want a 3rd form to open to a specific record.  \\Here is my onclick code of the hyperlink field but it is not working.   Can someone assist?

        DoCmd.OpenForm "frmLessons", acNormal, , "[ID]='" & Me.txtID & "'", acFormReadOnly, acWindowNormal

--Steve
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

This is because the text in a hyperlink field contains a bunch of html codes in addition to the ID that you are actually see in the field.

That is why most professional developers will encourage you not to use the hyperlink data type, but to use text instead.  There are a number of ways to actually launch the application associated with a hyperlink without actually using a hyperlink data type.
Is it a hyperlink data type?  Hyperlinks are not used this way.  they are not simple ID's as you seem to be expecting.

Is the form opening and you are not finding the record you expect or is the form not opening at all?  "Not working" isn't a helpful statement.  You have to tell us what is happening, including any messages and what you expected to happen although in this case, it is pretty clear what you expected to happen.
Avatar of SteveL13

ASKER

The field in the table is a text field.  But on the form I set "Is Hyperlink" to yes.  Nothing happens when I click it.
did you use the click event of the control  "txtRecord" ?

private sub txtRecord_click()

DoCmd.OpenForm "frmLessons", acNormal, , "[ID]='" & Me.txtID & "'", acFormReadOnly, acWindowNormal

end sub
oh, and another thing about this "Is Hyperlink" set to yes, control
- the focus must not be in the control you are going to click.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial