Results 1 to 13 of 13
  1. #1
    accessnewb is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    New York, NY
    Posts
    116

    Exclamation Hyperlink to open a form

    I have a search button and onClick of the search button a query is executed and filters the results in datasheet view. Is it possible for a field in the datasheet view to have a hyperlink and when I click on it, I should be able to view the corresponding form? (the form is also in the same db) Imagine the hyperlink is for the field strEmpID, then when I click on a particular field, based on the strEmpID, a form should open.


    When I googled for hyperlinks in access, most of the websites talk about linking to an external file or a webpage. Is there any way to open a form in the same DB?
    Last edited by accessnewb; 07-26-2011 at 05:30 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Wrong approach. Use double click event of the form displaying the datasheet view to run code to open form. Like:

    Private Sub Form_DblClick(Cancel As Integer)
    DoCmd.OpenForm "form name here", , , "filter criteria here"
    End Sub

    Open the same form for all records but filtered to the one EmpID? So filter criteria would be like:
    "strEmpID='" & Me.textboxname & "'"

    User would double click in the left margin of record to trigger this event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    accessnewb is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    New York, NY
    Posts
    116
    umm..doesn't work? Maybe I totally misunderstood what u said, but my understanding is: let's say I have a form called "products" which has a search button and onClick of this button, a query is executed and the results are filtered in datasheet view. So on the doubleClick event of the form "products", I gotta write the code you have given? I did that and I tried clicking the left margin of the filtered results and nothing got triggered!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The filtered results are on the same form as the search button? Or is this a subform? Post all relevent code for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    accessnewb is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    New York, NY
    Posts
    116
    The filtered results are in another form. I have another form called frmSearchResults and this form is linked to a query. So when I click on the products form, the query is triggered and frmSearchResults open with the filtered results. This is what I coded:

    Private Sub Form_DblClick(Cancel As Integer)
    DoCmd.OpenForm "frmSearchResults ", , , "FPItem='" & Me.FPItem & "'"
    End Sub

    this code is in the double click event of the 'products' form

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If I understand, this is what needs to happen.

    1. Click button on Products form. Code in button Click (not form DoubleClick) event to open frmSearchResults. Or eliminate the button and use AfterUpdate event of the control where the FPItem is selected (a combobox?).

    2. DoubleClick on record in frmSearchResults to open another form filtered to specific employee ID. It is behind frmSearchResults where my suggested code belongs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    accessnewb is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    New York, NY
    Posts
    116
    oh cool it works now! But instead of double clicking the left margin, can I double click on the field? Maybe have a hyperlink on the field? My worry is that the users are not gonna know that this is a clickable datasheet.

  8. #8
    accessnewb is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    New York, NY
    Posts
    116
    hey figured it out! Instead of coding in the doubleClick event of the form, I coded on the click event of the field in the frmSearchResults form. I also made that field into a hyperlink, so now it works like a charm!

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't think hyperlink will work to open objects within the project. The controls have Click and DblClick events. Try the code there. Is frmSearchResults locked against editing?

    Congratulations! I was composing reply just as you posted. Not sure how having the field as a hyperlink contributes to this success.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Access_Blaster is offline User
    Windows XP Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Hi June7,

    Are you saying that hyperlinks will not open objects (Forms, Tables, Querys) and paths within a database? Or am I missing your point.

    [QUOTE=June7;69451]I don't think hyperlink will work to open objects within the project. The controls have Click and DblClick events. Try the code there. Is frmSearchResults locked against editing?

    Richard

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I am saying I don't understand how a hyperlink could. If you or someone else knows otherwise, please explain.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    Access_Blaster is offline User
    Windows XP Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Quote Originally Posted by June7 View Post
    I am saying I don't understand how a hyperlink could. If you or someone else knows otherwise, please explain.
    Sure, I use the Hyperlink dialog box from the insert menu in design view Ctrl+k. In the left pane of the dialog box I select "objects in this database" No big deal I thought this was common practice.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Interesting, I was trained to use VBA to open forms and reports. Filtering criteria is passed to the form/report when it opens. I don't build reports/forms with a lot parameter criteria. I presume your forms/reports opened by hyperlink have parameters that refer to the calling form to get filter criteria?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-31-2011, 03:19 PM
  2. Open up url page hyperlink not working!
    By riffraff_ashraf in forum Forms
    Replies: 1
    Last Post: 09-29-2010, 09:33 AM
  3. Replies: 9
    Last Post: 09-19-2010, 09:18 PM
  4. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  5. Form Variable in Hyperlink
    By russ0670 in forum Forms
    Replies: 5
    Last Post: 01-15-2010, 08:09 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