Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    COMPILE ERROR To Follow Hyperlink - Help Needed

    Need Assistance, Please tell me where am I making a mistake, If There is no data in the field




    Private Sub Image94_Click()
    If Dir(PurAtt2.Text) <> "" And PurAtt2.Text <> "" Then
    Application.FollowHyperlink PurAtt2
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If


    End Subb

    When I click on the image No 2 on the Form I am Getting the following error


    COMPILE ERROR:
    METHOD OR DATA MEMBER NOT FOUND






    On the Form if I click on image No 1 I dont get error.
    for which I am using the following code



    Private Sub Image97_Click()
    If Dir(PurAtt1.Text) <> "" And PurAtt1.Text <> "" Then
    Application.FollowHyperlink PurAtt1
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The first thing is to double check the spelling of the control. If you use Me, you'll get intellisense that will double check your spelling. Type "Me." and the various controls and such should show up. If that's not it, what is the type of control (textbox, etc).

    Also, you shouldn't need the .Text property. I'm somewhat surprised you don't get an error, but I imagine images can't get focus so it stays on the control.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thx pbaldy for your help
    The Controle Type For PurAtt4B is IMAGE
    I have used the following code and it works as long as there is data in the field PurAtt4. But if the PurAtt4 has no data (i.e hyperlink) then I Get the Microsoft Visual Basic Run Time error 13 Type Mismatch.


    Private Sub PurAtt4B_Click()
    If Dir(Me.PurAtt4) <> "" And Me.PurAtt4 <> "" Then
    Application.FollowHyperlink PurAtt4
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I expect PurAtt4 is Null when there is no data - that would cause the Type Mismatch error with Dir().

    If Dir(Nz(Me.PurAtt4,"")) <> "" Then
    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
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thx June

    I applied the following code and it works perfectly



    Private Sub PurAtt4B_Click()
    If Dir(Nz(Me.PurAtt4, "")) <> "" And Me.PurAtt4 <> "" Then
    Application.FollowHyperlink PurAtt4
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't need And Me.PurAtt4 <> ""
    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
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    June

    If I use the following code as suggested by you

    Private Sub PurAtt4B_Click()
    If Dir(Nz(Me.PurAtt4, "")) <> "" Then
    Application.FollowHyperlink PurAtt4
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub


    Then I am getting the following error

    Run-time error '94':
    Invalid use of Null



    But with the following code no errors its works perfectly

    Private Sub PurAtt4B_Click()
    If Dir(Nz(Me.PurAtt4, "")) <> "" And Me.PurAtt4 <> "" Then
    Application.FollowHyperlink PurAtt4
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub




    Await your comments

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  9. #9
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Orange

    If Len(Dir(Me.PurAtt4)) = 0 Then 'file doesn't exist


    This does not work still gives error


    Pls tell me what is wrong with the following code



    Private Sub PurAtt4B_Click()
    If Dir(Nz(Me.PurAtt4, "")) <> "" And Me.PurAtt4 <> "" Then
    Application.FollowHyperlink PurAtt4
    Else
    MsgBox ("No Document Attached."), vbExclamation
    End If
    End Sub




    And why should not I stick to this code where as I mentioned earlier that this code is not giving any error.

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Type the following into the immediate window and show me what you get
    ? Dir("")

    I bet it's not what you where expecting.
    Try

    Code:
    Private Sub PurAtt4B_Click()
    If Len(Me.PurAtt4 & "")  > 0 Then 
       If Not Len(Dir(Me.PurAtt4) = 0 Then 
          Application.FollowHyperlink PurAtt4
       Else
           MsgBox ("No Document Attached."), vbExclamation
       End If
    End If
    End Sub
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I tested:

    ?Dir("") = ""

    which returns True

    as does

    ?Dir(Nz(Null,"")) = ""


    And this works for me:

    If Dir(Nz(Me.PurAtt4, "")) <> "" Then


    If you want to provide your db for analysis, follow instructions at bottom of my post.

    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
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  13. #13
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    aamer,

    I suggest you post a copy of your database as June7 recommended.

  14. #14
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Dir("") = "" isn't what was suggested?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    It was just a test to show that Dir("") returned a value equivalent to an empty string - at least it does for me. Trying to understand why my suggested condition does not work for the OP.
    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.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-30-2025, 03:14 PM
  2. dblClick textbox to follow hyperlink
    By markjkubicki in forum Programming
    Replies: 9
    Last Post: 03-11-2022, 06:18 PM
  3. Replies: 7
    Last Post: 10-27-2021, 08:42 AM
  4. Follow Hyperlink Method
    By philip.mccollum in forum Access
    Replies: 1
    Last Post: 07-08-2015, 05:57 AM
  5. Add button to follow hyperlink in table
    By stanley721 in forum Forms
    Replies: 6
    Last Post: 06-22-2013, 08:49 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