Results 1 to 5 of 5
  1. #1
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165

    Runtime Error 462

    I posted a code snippet earlier today. The code below grabs the operating system of a remote computer:

    Code:
    Private Sub cmdCheckStatus_Click()    Dim strComputer As String    Dim objWMIService As Object
        Dim colItems As Object
        Dim objItem As Object
    
    
        strComputer = Me.txtMachine.Value
        
        Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    
        Set colItems = objWMIService.ExecQuery( _
            "Select * from Win32_OperatingSystem", , 48)
    
    
        For Each objItem In colItems
            CompName = Nz(objItem.Name, 0)
        Next
            PipePosition = InStr(1, CompName, "|")
            CompName = Left(CompName, PipePosition - 1)
            Me.txtCheckStatus.Value = CompName
        Set objItem = Nothing
        Set colItems = Nothing
        Set objWMIService = Nothing End Sub
    My issue is that i get an error if the host can't be reached. Is there any way to supress the error?

  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,518
    Add error handling:

    http://www.baldyweb.com/ErrorTrap.htm

    and handle that error number however you want.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    "The code below grabs the operating system of a remote computer:" umm

  4. #4
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    Thank you. I haven't had to do a ton of error handling in the past. I am glad that I have a method to do so now. Very easy.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2016, 12:34 PM
  2. Replies: 2
    Last Post: 08-22-2015, 11:26 AM
  3. Runtime 438 error
    By Thompyt in forum Programming
    Replies: 2
    Last Post: 06-04-2015, 10:35 AM
  4. Replies: 2
    Last Post: 10-15-2014, 04:23 AM
  5. Replies: 13
    Last Post: 06-12-2012, 09:52 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