Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User-Defined Type not Defined

Status
Not open for further replies.

AlphaStu

Programmer
Mar 8, 2005
11
GB
Hi, I am new to VB.NET and have created an assembly that I reference in MS Access 2003. The problem is when I try to compile the Access database after adding in the reference I get the 'User-Defined Type Not Defined' compile error message and I believe it is something to do with the way I have written my code in .NET. All I will be doing in Access is typing a name in a form and clicking a button to display a greeting (using ShowGreeting). When the name is changed it uses the RaiseError to display a different message. Surely that should be simple!!

Below is the code, please could someone tell me what I have done wrong? Many thanks Stuart


Imports System.Runtime.InteropServices

Namespace EventSource
Public Delegate Sub NameChangedHandler(ByVal NameStr As String)

<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)>
Public Interface IMyInterface
Sub NameChanged(ByVal NameStr As String)
Property GreetingName() As String
Sub ShowGreeting()
End Interface

<ComSourceInterfaces(GetType(IMyInterface))> Public Class NETTest
Public Event NameChanged As NameChangedHandler
Dim lgNameStr As String

Public Property GreetingName() As String
Get
GreetingName = lgNameStr
End Get
Set(ByVal Value As String)
lgNameStr = Value
RaiseEvent NameChanged(lgNameStr)
End Set
End Property

Public Sub ShowGreeting()
MsgBox("Hello " & lgNameStr)
End Sub

End Class

End Namespace
 
try to under stand here, you wrote this code in .Net, then added it to access 2k3? So far as I know, Access 2k3 is still COM based, which would mean no .Net. But I've heard something about a tool set for office that works with .Net (Visual Studio Tools for the Microsoft Office Systems)

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Thanks for that Rick.

I've just managed to get it working by playing around with the references - phew!!
 
Out of curiocity, are you using .Net code in Office 2k3? If so, I may need to talk to the boss about upgrading.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Office 2k3 programming is still basically VBA, but you can use compiled .NET libraries as far as I know..
 
Ahh, that's a step in the right direction. Now if I can just use .Net to work with office. We have a few apps that use Word COM object to run mail merges. Talk about finiky pieces of garbage.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
All I did was create my class in VB.NET and registered it for COM interop when I build it. In Access 2003 I referenced the resulting .tlb file and was able to use it as previous DLL's from VB6. Bit of a fiddle to get the event handling and intellisense to work though!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top