Solved

User Defined Types

Posted on 2001-07-02
12
172 Views
Last Modified: 2012-06-27
Could someone please tell me what the following statement means and how can I get around it. I am trying to use the IsEmpty function on a user-defined type.

"Only User-Defined Types defined in Public Object modules can be coerced to or from a variant or passed to late-bound functions."

Here is my if statement I am trying to use:
If IsEmpty(strPMActivities) = False Then

My strPMActivities() as udtPMData is my user defined type and is declared with in a function and is passed to other functions.

Liz
0
Comment
Question by:eware
  • 5
  • 5
  • 2
12 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 6246077
IsEmpty only returns meaningful information for variants.  UDT is not a variant, so find another way to figure out if it is initialized or not.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6246157
could you post some more code where you use it?
0
 

Author Comment

by:eware
ID: 6246170
If IsEmpty(strPMActivities) = False Then
    For I = 1 To UBound(strPMActivities)
        Set lsvData = frmRunSchedule.lsvPMSchedule.ListItems.Add(, ,                strPMActivities(I).intPMID)
        With lsvData
            .SubItems(1) = strPMActivities(I).strMesaPMID
            .SubItems(2) = "SCHEDULED"
            .SubItems(3) = strPMActivities(I).strActName
        End With
    Next I
end if

Basically says if there is data in the array, do the for loop below. I have many udt's and have tried a function that will send me back an integer, 0 for no data and 1 for data, but I would need a function for each data type.

Liz
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 6246182
>>>
Basically says if there is data in the array, do the for loop below. I have many udt's and have tried
a function that will send me back an integer, 0 for no data and 1 for data, but I would need a function
for each data type.
<<<

Use error trapping on Ubound

dim lngUBound as long

On Error resume next
lngUbound = Ubound(strPMActivities)


If err.Number = 0 then
   On Error Goto 0
   For I = 1 To lngUBound
       Set lsvData = frmRunSchedule.lsvPMSchedule.ListItems.Add(, ,                strPMActivities(I).intPMID)
       With lsvData
           .SubItems(1) = strPMActivities(I).strMesaPMID
           .SubItems(2) = "SCHEDULED"
           .SubItems(3) = strPMActivities(I).strActName
       End With
   Next I
end if
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6246185
Might want to add this at the end

On Error Goto 0


Otherwise, error trapping still in effect if no data in array.
0
 

Author Comment

by:eware
ID: 6246240
Could I have multiple On Errors in a function/
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6246250
You can't nest them if that's what you mean.
0
 

Author Comment

by:eware
ID: 6246255
What I meant by my previous question was I have On Error Goto Errorhandler as well. Is it possible to have multiple On Errors and it know which one to go to?
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6246257
But you can temporarily change your default error handler to take something different...

On Error goto errHandler  'default error handling

....code and stuff

on error resume next  'change default handler
if err.number = 0
  ''blablabla
end if
on error goto errHandler  'turn default handler back on
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6246432
A little comment, what is strPMActivities? Array or UDT?
i missed something!
0
 

Author Comment

by:eware
ID: 6246480
I am glad that someone knows how to catch these errors. It is really difficult when you can't find an answer in the help. It is alot of work because I have these ubounds everywhere, but If it does what I need it to do, I will use it. Thank you for your help.

Liz
0
 

Author Comment

by:eware
ID: 6246487
strPMActivities is a UDT.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

808 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