Object Methods

  • Thread starter Thread starter Doekoe
  • Start date Start date
D

Doekoe

I want to open from a Access DB another program. I use an Object from
this program which I access with the CreateObject function. I put the
code in the OnClick event of a command button en this works fine. The
program opens with the right information.

Now I would like to use this code from different places so I decided
to put this code in a Function in a Module. The problem I encounter
now is that I get a message that 'This property of method is not
supported by this object'.

What can be te reason that a method is not supported in the function,
but works fine in a forms OnClick event of a button?

Thanks in advance.

Dirk
 
Most likely, it is the Scope of the object variable that is the problem.
Where do you Dim the object variable?
Posting your code would give us a better idea of what is happening.
 
Most likely, it is the Scope of the object variable that is the problem.
Where do you Dim the object variable?
Posting your code would give us a better idea of what is happening.
--
Dave Hargis, Microsoft Access MVP









- Tekst uit oorspronkelijk bericht weergeven -

Hi Dave,

I already put the code back to the OnClick event of the button. I can
give you here the code block where execution stops:

Public Function TokOpen(sDebiteur As String, sDrawer As String)

Dim tok, cri As Object
Dim zoekveldindex As String

Set tok = CreateObject("TOKOPEN.TOKOPEN_VIEW")

'some code that is working fine

tok.criteria.Clear
Set cri = CreateObject("TOKOPEN.TOKOPEN_CRITERIA")
cri.FIeldName = Zoekveldindex
cri.Condition = 1
cri.Fieldvalue = sDebiteur
tok.criteria.Add (cri) 'here the message comes up

'rest of code which can not be executed

End sub

The line "tok.criteria.Add (cri)' gives the problem. It seems to me
that 'ADD' is the method which is not supported. But I have no idea
why not. I hope you can do something with it. If not I will try to
find time to put the complete function here.

Thanks in advance.

Dirk
 
tok is not dimmed as an object. It is dimmed as a variant.
Dim tok, cri As Object

First, I don't care for dimming multiple variables on one line. A line for
each variable makes it easier to read. Also, when you don't identify a type
in a Dim statement, it defaults to Variant. You may thing that all varialbes
on the line dim as the type stated for the last variable, but that is not
true. What you have translates to:
Dim tok As Variant, cri as Object.

It should be
Dim tok As Object, cri as Object.

Or my preference
Dim tok as Object
Dim cri as Object
 
tok is not dimmed as an object.  It is dimmed as a variant.
Dim tok, cri As Object

First, I don't care for dimming multiple variables on one line.  A line for
each variable makes it easier to read.  Also, when you don't identify a type
in a Dim statement, it defaults to Variant.  You may thing that all varialbes
on the line dim as the type stated for the last variable, but that is not
true.  What you have translates to:
Dim tok As Variant, cri as Object.

It should be
Dim tok As Object, cri as Object.

Or my preference
Dim tok as Object
Dim cri as Object

--
Dave Hargis, Microsoft Access MVP

















- Tekst uit oorspronkelijk bericht weergeven -

Hi Dave,

Thanks for you answer, this is probably the problem. I will try it. I
did not know this. I thought that all variables got the Object type. I
see more programmers use this type op Dimming, that was why I start
using it too. But I agree it easier to read the way it should be done.

Thanks.

Dirk
 
I use this method because I have been programming for over 30 years and have
the scars to prove it :)
 
Back
Top