Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    82
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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 06:17. Reason: Added Code Tags

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,869
    Thanks
    0
    Thanked 180 Times in 165 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]

  4. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 766 Times in 700 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

    VBA Rules!

    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
  •