Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    Registry entry not returned

    The code has been in use in this database for well over a decade but is now a problem but only on some machines The code is currently running on 2010 and 2013.
    --test code with the problem value--
    Code:
    Private Sub Command2_Click()
      Me!Text0 = Mid(RegKeyRead("HKEY_CURRENT_USER\Network\P\RemotePath"), 22)
      Me!Text3 = RegKeyRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOwner")
      Me!Text4 = RegKeyRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization")
    End Sub
    
    Function RegKeyRead(i_RegKey As String) As String
      Dim myWS As Object
      On Error Resume Next
      Set myWS = CreateObject("WScript.Shell")
      RegKeyRead = myWS.RegRead(i_RegKey)
    End Function
    There are 10 computers using this database, most of them on runtime versions of Access 2010. Four computers were just updated to Windows 7 and now two of them won't run because this code fails.

    The first two registry calls return the correct values, the third returns an empty string even though there is a valid entry in the registry (we tried several).

    Any thoughts as to the source of the problem will be appreciated.
    Last edited by RetiredGeek; 2014-06-22 at 07:17. Reason: Added Code Tags

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    I'm surprised either of your 2nd & 3rd parameters return anything with 'Microsoft\ Windows NT\' - it should be 'Microsoft\Windows NT\'. FWIW, with that fixed, both of those parameters report correctly on my Win 7 system.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Note Paul responded before I added the Code tags. The lounge has a bad habit of adding spaces to long strings if not included in Code or NoParse tags. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •