User Defined Type error when creating UDTs

  • Thread starter Thread starter Bula
  • Start date Start date
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
 
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.
 
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
 
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
 
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>
 
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.)
 
Back
Top