WithEvents syntax

  • Thread starter Thread starter Chubbly Geezer
  • Start date Start date
C

Chubbly Geezer

Hi

I have written a DLL that raise several events. I want to use this DLL and
the associated events within Access 2003 but cannot seem to find the correct
syntax of the WithEvents.

In VB I would just dim the dll using the Withevents and then the events
would appear in the procedure list which I could select and use.

This is not the case in Access. Any ideas please.

Chubbly
 
If you declare an instance of a Class in Access VBA with the following
syntax:

Dim WithEvents Something As clsMyClass

in the declarations section of the relevant module, the Public Events of the
class definitely appear in the procedures list

Does this help?
 
Well that's what I thought, but they don't.

Could it be that I am using a .Net dll via a tlb file?

My declaration is in the declarations section and looks fine

Dim WithEvents WWinTI As WWinTiNET.clsCardAuthorisation
 
have you added a reference to the dll?
open Module/tools/references

Pieter
 
have you added a reference to the dll?
open Module/tools/references

Pieter

Chubbly Geezer said:
Well that's what I thought, but they don't.

Could it be that I am using a .Net dll via a tlb file?

My declaration is in the declarations section and looks fine

Dim WithEvents WWinTI As WWinTiNET.clsCardAuthorisation



--
 
If I add a ref to Excel for example and declare an instance of that, it does
indeed add entries to the procedures list.


"Pieter Wijnen"
 
You're right. It seems it won't work with tlb's, just Dll's & Ocx's. I
don't know enough about tlb's to understand why although I noticed that if
you browse to add a reference and pick a tlb Access actually sets the
reference to an identically named dll if it exists.

HTH
 
So it seems that if I have a .Net dll, I'm stuffed.

Seems unlikely. Check it out first with an Excel or Word object
to check that you are getting it right. You are putting the declaration
in a class module?

(david)
 
That's not true, you can set a reference to a .tlb file and then use
withevents.
 
Is your .tlb file registered ?

--

Terry Kreft


Chubbly Geezer said:
So it seems that if I have a .Net dll, I'm stuffed.


<it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
..with.norway>
 
You're right of course Terry. It must be that the tlb's I tried had no
classes with public events so the declared object does not show in the
object box in those circumstances.
 
Could well be, the easy ones to prove it with is one of the ADO tlbs.
 
OK it seems that I had to flag my .Net assembly as a Com Class.
i.e.
<Microsoft.VisualBasic.ComClass()> Public Class clsCardAuthorisation

I can indeed now reference the dll from within Access and the event shows.
However, the code I have placed within it does not appear to run. This is
exactly the same code as I use in a .Net test app that calls the dll. The
event is being raised but nothing appears to reach Access. Am I maybe
missing something else?
 
Please ignore that. Working fine.

thx

Chubbly Geezer said:
OK it seems that I had to flag my .Net assembly as a Com Class.
i.e.
<Microsoft.VisualBasic.ComClass()> Public Class clsCardAuthorisation

I can indeed now reference the dll from within Access and the event shows.
However, the code I have placed within it does not appear to run. This is
exactly the same code as I use in a .Net test app that calls the dll. The
event is being raised but nothing appears to reach Access. Am I maybe
missing something else?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top