?
Solved

MS Access AddReference over network - DCOM

Posted on 2010-11-09
7
Medium Priority
?
293 Views
Last Modified: 2012-05-10

The code below attempts to start a VB created application called Entry with a SetID class and Function by the same name.  It works as long as it is run on the local machine, but I also want it to run over a network path - and run the Entry app from the remote machine.  This is where it fails.

In spite of the fact that the GetDBPath  Function gets the remote network path, the References.AddFromFile call adds the reference from the local DB path, if the file exists.  If it does, it runs it from the local machine.  If it does not exist, the CreateObject("Entry.SetID") call fails.

In addition, I cannot successfully add a reference in Access VBA (Tools/References...) to this remote network 'Entry.exe' at all.  It simply does not add it, with no messages as to why.

The local machine has full rights to the remote machine as well as launch, etc. permission in dcomcnfg.  I also checked 'Allow Trusted Locations on my network' in the MS Access Trust Center.

Thanks

Chas Callaway
Private Sub cmdEntry_Click()
  On Error GoTo exitcmdEntry
  Dim EntryID As Object
  Dim VBReferens As Reference
  Dim msg As String

	'look for an "Entry" reference and remove it
  For Each VBReferens In References
    If VBReferens.Name = "Entry" Then References.Remove VBReferens
  Next VBReferens
  msg = "AddFromFile"

  	'Add reference from to 'Entry.exe" from the file location of the database
  References.AddFromFile GetDBPath & "Entry.exe"
  msg = "Set EntryID"
	'start 'Entry.exe'
	'if the file does not exist locally, this fails, even if the location is over the network
  Set EntryID = CreateObject("Entry.SetID")
  Dim dbs As Database
  Dim rs As Recordset
  Set dbs = CurrentDb
  Set rs = Me.Recordset
  'Call the EntryID.SetID Function
  EntryID.SetID rs("Entry ID")
  Set rs = Nothing
  Set dbs = Nothing
	'look for an "Entry" reference and remove it
  For Each VBReferens In References
    If VBReferens.Name = "Entry" Then References.Remove VBReferens
  Next VBReferens
  Exit Sub
exitcmdEntry:
  MsgBox msg & "-" & Err.Description
End Sub

Public Function GetDBPath() As String
  GetDBPath = CurrentProject.Path & "\"
End Function

Open in new window

0
Comment
Question by:chascallaway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 2000 total points
ID: 34096132
There are two ways to do this,

1) you can explicitly use it over the network by using
Set EntryID = CreateObject("Entry.SetID", "Machine") BUT you cannot add a reference into your design time

2) You can add a reference to DCOM on the client that says "Entry" is on this other machine,
and then you can reference it AND use it as if it were local

0
 
LVL 16

Assisted Solution

by:JohnBPrice
JohnBPrice earned 2000 total points
ID: 34096194
For 2), you need to compile Entry.exe and get the .tlb file for it.  The .tlb defines the public interface that the exe supports.  You must also muck with dcomcnfg to point things to the right places and with the right security.

see http://support.microsoft.com/kb/268550

see also for issues with service packs
http://support.microsoft.com/kb/892500
0
 
LVL 16

Assisted Solution

by:JohnBPrice
JohnBPrice earned 2000 total points
ID: 34096238
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:chascallaway
ID: 34099076
John:

Thanks for the prompt reply.  The help I have gotten from Experts Exchange has been invaluable.

The link to a proper DCOM configuration was helpful.  I'm sure that I had DCOM comfigured incorrectly, but this was not enough.  I did successfully add a reference at design time, even after deleting (moving) the .tlb file.

In addition to a likely DCOM configuration, the problem turned out to be that this code:
Set EntryID = CreateObject("Entry.SetID")
was first wrong because it will always try to connect to the local machine.  I totally ignores the path in the reference to 'Entry' unless the machine name is included, like this:
Set EntryID = CreateObject("Entry.SetID","MachineName")
However, this also fails, so I tried some code I had used in a different DCOM application:
Set EntryID = New Entry.SetID
This works and respects the path created for 'Entry' with:
References.AddFromFile GetDBPath & "Entry.exe"

If I could code the DCOM configuration, this would be operator agnostic.

Many thanks for your help.

Consider the case closed.

Chas Callaway
0
 

Author Closing Comment

by:chascallaway
ID: 34099084
Set EntryID = CreateObject("Entry.SetID","MachineName")
However, this also fails, so I tried some code I had used in a different DCOM application:
Set EntryID = New Entry.SetID
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 34101250
Set EntryID = New Entry.SetID works if you have a valid reference (and it makes coding a lot easier.  Create Object should work, but you may still have to adjust the DCOM stuff to get the right permissions on server and client.

cheers.
0
 

Author Comment

by:chascallaway
ID: 34103426
Thanks for your help!

Chas Callaway
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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