Results 1 to 12 of 12
  1. #1
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117

    Error message code

    I have the following code on the DblClick of a Form combo field called "SUPPLIER".


    When clicked it opens up a network folder which matches to the Supplier name in the combo.

    Application.FollowHyperlink "\\serverone\quality system\ncr information\consolidated folders\" & Me.Supplier

    Can anyone help me with the code for an error message if either the record doesn't match or doesn't exist i.e there is no folder on the network

    Thanks

  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,521
    The method I've seen is to test first with the Dir() function to see if it exists (with the Len() function).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Hello Paul
    My knowledge of code is very much still at the infant stage as such all I can do at the moment is mimmick what I am either reading or being told.
    I do not understand what you mean, so can you either put it in baby language or just write the code for me to cut and paste.
    Thanks for the reply

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Didn't even want to try?

    If Len(Dir("YourPath")) > 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Hello Paul
    I have just added
    If Len(Dir("\\serverone\quality system\ncr information\consolidated folders\" & Me.Supplier)) > 0 then
    as another line of code
    I get the following messge
    Block If without End If

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not surprising, since that was just intended to point you in the right direction. Look in VBA help for the proper syntax of an If/Then/Else block.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    Not too sure why you made the comment "Didn't even want to try ?" if you were then going to follow up with the next "Not surprising........" remark
    The reason why I said I was at the infant stage was so that I didn't get "smart" answers like this.
    I was always of the opinion that these forums were there to help and guide people through problems.In this case, obviously note.
    I am pretty proficient at my own job, and if someone asked for help and I could give it, I would help them as much as possible. One thing I wouldn't do is give some smart ***e answer because I knw something they didn't

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I apologize for hurting your feelings. However, as you said "forums were there to help and guide people through problems" which is what I'm trying to do; guide you. Teach you to fish, not give you the fish. You seem to want the fish, so here you go.

    Code:
    If Len(Dir("\\serverone\quality system\ncr information\consolidated folders\" & Me.Supplier)) > 0 then
       Application.FollowHyperlink "\\serverone\quality system\ncr information\consolidated folders\" & Me.Supplier
    Else
       Msgbox "Path doesn't exist"
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    In this particular instance, I had actually looked through the forums, looked at the help and tried several attempts at code. All were unsuccessful. I have successfully written some other simple "If...Then..ElseIf code to open a range of similar reports, however in this particular case, I believe network path was defeating me.
    Anyway, I have inserted the code and it works fine, so thank you very much for your help

  10. #10
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    OOPS - Tried it again - now it doesn't.
    It gives the "Path doesn't exist" for all returns even if the Supplier name matches

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If that's a folder, a brief test would indicate that you need to add the trailing "\". Without it, it thinks you're looking for a file by that name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    FJM is offline Competent Performer
    Windows 98/ME Access 2003
    Join Date
    Jun 2010
    Posts
    117
    I have tired the change but to no avail. I have decided to simply let the access default warning message appear if there is no record and click the end button. I get the result I want so its' a result in one way.
    Thanks for your help

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

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. Error Message
    By Alex Motilal in forum Access
    Replies: 2
    Last Post: 06-03-2013, 10:56 PM
  3. Error message 'Error in Loading DLL'
    By rahayes in forum Programming
    Replies: 2
    Last Post: 09-22-2012, 05:17 AM
  4. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  5. Alert Message Code Problem
    By 10 Gauge in forum Forms
    Replies: 1
    Last Post: 03-15-2011, 12:17 PM

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