wordpress statistics
  • Today is Friday, May 18, 2012

13 Responses to “Open Forms with Hyperlinks in Listbox”

  1. many thanks to you
    but can you up to us an examole to see that

    or send it to me at : ahmedtharwat19@yahoo.com

  2. Yes, I will forward a sample database to you shortly.

    regards,
    a.p.r. pillai

  3. Yes, this is possible. Sample Code is given below:

    Private Sub cboModel_Click()
    Dim myhype, xy As String, xcboModel
    Dim db As Database, rst As Recordset

    xcboModel = Me![cboModel]

    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblModel", dbOpenDynaset)

    rst.FindFirst "ModelID = " & Chr$(34) & xcboModel & Chr$(34)

    If Not rst.NoMatch Then
    Set myhype = rst![Hlink]
    xy = HyperlinkPart(myhype, acAddress)
    Me.cmdPDF.HyperlinkAddress = xy
    End If

    rst.Close
    End Sub

    The above Code Runs when you Click on the cboModel ComboBox. Searches the Table for the Model Value selected in the Combo Box and when found retrieves the HyperLink Value into myhype Variable. The HyperLinkPart() Function extracts the .pdf file pathname from the Hyperlink Field. The extracted Path is inserted into the HyperLink Address Property of the cmdPDF Command Button. When you Click the Command Button the PDF File will be opened.

    The Hyperlink Field Value in the tblModel must be set in the following format:

    Display Text#pdf File PathName##Tooltip Text

    Example:

    Model Document#C:\My Documents\Lexus.pdf##Click

    You may visit the following link to learn how to refresh a ComboBox contents that depends on another ComboBox value selection:

    http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents/

    Regards,
    a.p.r. pillai

  4. Anonymous says:

    Do you know how to connect a hyperlink to a command button that sends you to the hyperlink based on selections picked from combo boxes? Example to clarify:

    You want to set up a car database so you make tables with certain information regarding the car, but for the purpose of this, lets just look at the model table. The model table (tblModel) consists of the following fields: ModelID, ModelName, MakeID, Hyperlink. The MakeID would be a link if you had cascading combo boxes in the form. So from a form the user would select a Make (cboMake), which would then break down the Models (cboModel). Based on the selection made by the user for the model the code in the command button would compare the model selected in cboModel to the model in tblModel and return the hyperlink (field 4) so that when the user clicked the command button he would see a pdf for that model.

    Thanks in advance
    Cory Hall – cory_r_hall@yahoo.com

  5. Cory says:

    The code works great, thanks a lot. Was just going to ask about two lines:

    Set rst = db.OpenRecordset("tblModel", dbOpenDynaset)
    rst.FindFirst "ModelID = " & Chr$(34) & xcboModel & Chr$(34)

    I know if you have spaces in your titles such as Model ID instead of ModelID, you usually put the name in brackets such as [Model ID], but it seems for both tblModel and ModelID above it gives debug errors when you bracket them.

  6. You don't need to put [] in the first statement, even if there is space in the Tahle Name.

    But, if there is space in the ModelID Field Name then you must insert the square brackets. When you do see that you are not adding extra spaces immediately after or before the brackets.

    Regards,

  7. Cory says:

    With the following code, I'm trying to get a bit fancier and embed the pdf within the form. I'm using a microsoft web browser object to do this, but when i click the cmdPDF button it just shows a page that can't find the hyperlink. acxWebBrowser is the name of the web browser object.

    Private Sub cboModel_Click()
    Dim myhype, xy As String, xcboModel
    Dim db As Database, rst As Recordset

    xcboModel = Me![cboModel]

    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblModel", dbOpenDynaset)

    rst.FindFirst "ModelID = " & Chr$(34) & xcboModel & Chr$(34)

    If Not rst.NoMatch Then
    Set myhype = rst![Hlink]
    xy = HyperlinkPart(myhype, acAddress)
    Me.acxWebBrowser.Navigate "xy"
    End If

    rst.Close
    End Sub

  8. Remove the Quotes from Me.acxWebBrowser.Navigate "xy"

    Me.acxWebBrowser.Navigate xy

    and try again.

  9. Nurul Anuar says:

    Thanks for the idea, can you send me to nurulmarea@gmail.com the example of the database so that I can get the clear idea. Thansk and regards

  10. a.p.r.pillai says:

    I will forward a Demo Database to you shortly.

    Regards

  11. Sasa Kostadinovic says:

    Hello,

    Can I pass argument inside hyperlink?
    For Example:
    When I open hyperlink in edit mode looks like
    “Address: #Form Employees”
    Can I open form Employees to display specific Employee?
    Something like:
    Docmd.OpenForm Employees,WhereCondition:=”[ID]=”&51

  12. a.p.r.pillai says:

    Parameter Values cannot be passed through HyperlinkSubAddress. You have already shown the example through the Docmd.OpenForm method.

  13. Sasa Kostadinovic says:

    Hello again,
    Is there way to call Public Function or Public Sub with Hyperlink?

Leave a Reply

You must be logged in to post a comment.