User Defined Type error when creating UDTs

B

Bula

Hello:

I am trying to create a User Defined Type like this in an Access VBA
module:

Public Type Applicant
FirstName As String
LastName As String
End Type

Sub DefineUDT()

Dim uApp As Applicant

uApp.FirstName = "Dick"
uApp.LastName = "Kusleika"


End Sub

When I run the DefineUDT procedure, I got a "User Defined Type not
deifined error".

The same type and procedure can run in Excel VBA. I guess I should
refer to a library for the UDT or something.

Please help me to create an UDT in Access.
Thank you very much!


Zhu
 
O

OldPro

Hello:

I am trying to create a User Defined Type like this in an Access VBA
module:

Public Type Applicant
FirstName As String
LastName As String
End Type

Sub DefineUDT()

Dim uApp As Applicant

uApp.FirstName = "Dick"
uApp.LastName = "Kusleika"

End Sub

When I run the DefineUDT procedure, I got a "User Defined Type not
deifined error".

The same type and procedure can run in Excel VBA. I guess I should
refer to a library for the UDT or something.

Please help me to create an UDT in Access.
Thank you very much!

Zhu

Looks okay to me. Make sure the Public Type is in a public module,
and not a form module. The only other problem I can foresee is if the
name Applicant is already used somewhere else, or is a keyword.
Change it to uApplicant and see if that makes a difference.
 
M

mscertified

When you type 'uapp.' do you get the prompting for Firstname/Lastname. If
not, it is not finding the type.
Does your project compile?

-Dorian
 
K

Klatuu

You have not instansiated the type:

Sub DefineUDT()
Dim uApp As Applicant

Set uApp = New Applicant

uApp.FirstName = "Dick"
uApp.LastName = "Kusleika"

Set uApp = Nothing

End Sub
 
D

Douglas J. Steele

Well done, Dave!

It would appear that your note saying to disregard your previous post was
sent 2 minutes before the post we're supposed to ignore!

Now if only we could be sure you'd only use your prescience for good! <g>
 
K

Klatuu

Aha! Success at Last.
I have been working on random access time for a long time.
I figured if Billy Pilgrim could do it, I could.

(Actually, don't know how that happened.)
 

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

Top