Solved

Problem using GetObject("WinNT:")

Posted on 2004-08-27
2
1,854 Views
Last Modified: 2006-11-17
I'm currently using the following code to get a listing of all the domains in my LAN. It works fine, but every once in a while, GetObject returns nothing, and I have to recursively call the same routine untill it returns data. I'm confused as to why this is happenning. Can someone help?

Here is the code:

 Dim objNS As IADsContainer
 Dim objDomain As IADs
   
   Set objNS = GetObject("WinNT:")
 
   For Each objDomain In objNS
      cmbDomain.AddItem objDomain.Name
   Next
   
   MsgBox cmbDomain.ListCount
   
   If cmbDomain.ListCount = 0 Then
      Call Form_Load
   End If


* This is an extension of the following question :
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21004965.html
0
Comment
Question by:LeeHenry
2 Comments
 
LVL 1

Accepted Solution

by:
mkrell earned 500 total points
ID: 11927010
maybe this is because of a timeout while getting the object...

use:

Do
   Set objNS = GetObject("WinNT:")
Loop until  not (objNS Is Nothing)

instead of your recursive way.
0
 
LVL 6

Author Comment

by:LeeHenry
ID: 11931107
Thanks for the response. I'll give this a try this afternoon.

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now