[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

User Defined Types

Posted on 2001-07-02
12
Medium Priority
?
178 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 38

Accepted Solution

by:
PaulHews earned 400 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
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…
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

873 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