Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159

    Hyperlink on a subform?

    I have a form with a subform. The subform is a list of all the records in the database. I would like to add a field to the subform table/list that would hyperlink the user to the record's profile form once clicked.



    I have a similar hyperlink in my database on another form and it works correctly, but for some reason, when I set the hyperlink up in my subform it doesn't direct to the correct record or it just opens the form to a blank record.

    I copied and pasted the fields from the form that worked into the subform and what I explained above is what happens.

  2. #2
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    I'm linking the subform to the Profile form through a field called ID. This field is on both Form's record source.


    Here is what I added for an On-Click Macro:
    Open Form: Prospect Form
    Where Condition: [ID]=[Forms]![Rosters]![ID]

    Where Roster is the name of the form with the subform. (The subform is named "SUB")

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by yes sir View Post
    I'm linking the subform to the Profile form through a field called ID. This field is on both Form's record source.


    Here is what I added for an On-Click Macro:
    Open Form: Prospect Form
    Where Condition: [ID]=[Forms]![Rosters]![ID]

    Where Roster is the name of the form with the subform. (The subform is named "SUB")
    remember that subforms have two very distinct attributes. the control name and the actual object name. try changing the where condition in the macro to:
    Code:
    [ID]=[Forms]![Rosters]![SUB].form![ID]
    the other thing to note is that if you try to reference that subform directly in a macro or in code, you'll always get an error that says 'object is not loaded', or something to that effect.

    so try that first. If that doesn't work use the syntax in code. I know it works there.

  4. #4
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Private Sub Txthyperlink_Click()
    DoCmd.OpenForm (Prospect_Form,acNormal,,[ID]=[Forms]![Rosters]![SUB].form![ID],,acWindowNormal,
    End Sub

    Compile Error:
    Syntax Error

    It highlights the first line in yellow, don't see what is wrong with that line. Upon opening VBA, that line is automatically entered by the system. I must be referencing something incorrectly.

  5. #5
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Uploaded the db.

    The Rosters Form has the subform on it. When in Design View, the field called ID with the hyperlink is having the issue.
    Last edited by yes sir; 10-07-2010 at 10:00 PM.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    It does that I think because you are not using quotes. The argment is a string Jay. And I don't think you can reference subforms in that aregument anyway. I couldbe wrong.

    I didn't know you were using this argument. Sorry

  7. #7
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Private Sub Txthyperlink_Click()
    DoCmd.OpenForm "Prospect Form", acNormal,,"ID = Forms!Rosters!SUB.form!ID",,acWindowNormal,
    End Sub

    Apparently this isn't correct either.

  8. #8
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Have you tried:
    DoCmd.OpenForm "Prospect Form", acNormal,,"[ID]=[Forms]![Rosters]![SUB].form![ID]",,acWindowNormal,

    Also, is "SUB" what you named the form used as a subform AND/OR the subform control on [Prospect Form]? The above line is pointing to a contol on [Prospect Form] named "SUB" not a form object named "SUB".

  9. #9
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Quote Originally Posted by slave138 View Post
    Have you tried:
    DoCmd.OpenForm "Prospect Form", acNormal,,"[ID]=[Forms]![Rosters]![SUB].form![ID]",,acWindowNormal,

    Also, is "SUB" what you named the form used as a subform AND/OR the subform control on [Prospect Form]? The above line is pointing to a contol on [Prospect Form] named "SUB" not a form object named "SUB".

    SUB: name of subform
    Rosters: name of form with the SUB (subform) on it
    Prospect Form: form that opens when hyperlinked field is clicked.

    Tried your code and still getting the syntax error

  10. #10
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    "[ID]=[Forms]![Rosters]![SUB].form![ID]"

    Obviously this part is the problem. ID is correct, and Rosters is the correct form that contains the subform. I'm just not pointing to the subform correctly.

  11. #11
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by slave138 View Post
    Have you tried:
    DoCmd.OpenForm "Prospect Form", acNormal,,"[ID]=[Forms]![Rosters]![SUB].form![ID]",,acWindowNormal,
    this is not allowed, as far as I know.

  12. #12
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    this is how you do it jay...

    (make sure to hold the SHIFT key down when opening because I have the menus turned off otherwise...)

  13. #13
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Quote Originally Posted by ajetrumpet View Post
    this is how you do it jay...

    (make sure to hold the SHIFT key down when opening because I have the menus turned off otherwise...)

    Maybe I'm not opening the db correctly. But what I'm looking for are hyperlinks on a subform that contains many records. Each record has the hyperlink. The subform part is taken care of.

  14. #14
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233

    Example please?

    Quote Originally Posted by yes sir View Post
    Maybe I'm not opening the db correctly. But what I'm looking for are hyperlinks on a subform that contains many records. Each record has the hyperlink. The subform part is taken care of.
    Can you post a copy of the Rosters form please?

  15. #15
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Quote Originally Posted by slave138 View Post
    Can you post a copy of the Rosters form please?
    I'll post the whole db and tell you what to look for. I just removed my last attachment, but I'll put it back up.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. how to insert a hyperlink?
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 09-16-2010, 07:37 AM
  2. How to email a hyperlink using VBA
    By Lockrin in forum Access
    Replies: 1
    Last Post: 07-16-2010, 02:29 PM
  3. Where is the hyperlink....
    By amer in forum Queries
    Replies: 1
    Last Post: 06-09-2010, 12:06 PM
  4. Hyperlink in Report?
    By cadsvc in forum Reports
    Replies: 0
    Last Post: 05-11-2010, 07:27 PM
  5. Hyperlink Help
    By smikkelsen in forum Access
    Replies: 9
    Last Post: 03-12-2010, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums