Solved

User Defined Types

Posted on 2001-07-02
12
171 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
VBA saving file message display 5 64
bit defender blocks good applications 2 94
Advice in Xamarin 21 79
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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