|
-
Apr 27th, 2006, 09:41 AM
#1
Thread Starter
Lively Member
I'm having trouble creating Type's in VBA
I made a type "Employee" in a class module.
Option Compare Database
Option Explicit
Private Type Employee
DateHired As Date
FullName As String
IsMarried As Boolean
HourlySalary As Currency
End Type
Then I'm trying to assign a variable as this new user defined type
in a sub function.
Private Sub cmdCreate_Click()
Dim Contracter As Employee
Contracter.DateHired = #12/4/2004#
Contracter.FullName = "James McNeil"
Contracter.IsMarried = False
Contracter.HourlySalary = 10
txtDateHired = Contracter.DateHired
txtFullName = Contracter.FullName
chkIsMarried.Value = Contracter.IsMarried
txtHourlySalary = Contracter.HourlySalary
End Sub
but an error saying " method or data member not found" keeps popping up for the .datehired
any suggestions?
-
Apr 27th, 2006, 09:59 AM
#2
Re: I'm having trouble creating Type's in VBA
VBA question moved to Office Development.
BTW: I had no problem running your code using VB6 so it has to be something with VBA. These folks should know.
-
Apr 27th, 2006, 10:00 AM
#3
Re: I'm having trouble creating Type's in VBA
I'm not sure about VBA (and this should be moved to the proper forum), but in VB it would be
VB Code:
Contracter.DateHired = "12/4/2004"
Try that.
-
Apr 27th, 2006, 10:03 AM
#4
Re: I'm having trouble creating Type's in VBA
are u trying to access the Type outside of the class module??
it seems that way since its under cmdCreate....
put it in a reg bas module.. and declare it as Public
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 27th, 2006, 10:04 AM
#5
Re: I'm having trouble creating Type's in VBA
 Originally Posted by Al42
I'm not sure about VBA (and this should be moved to the proper forum), but in VB it would be
VB Code:
Contracter.DateHired = "12/4/2004"
Try that.
no its a DATE do #12/4/2004# would be correct
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 27th, 2006, 10:13 AM
#6
Thread Starter
Lively Member
Re: I'm having trouble creating Type's in VBA
 Originally Posted by Hack
VBA question moved to Office Development.
BTW: I had no problem running your code using VB6 so it has to be something with VBA. These folks should know. 
yea i figured that was the main issue. thing is i been trouble shooting using vba sites and they are telling me what i did was ok. so iono
-
Apr 27th, 2006, 10:14 AM
#7
Thread Starter
Lively Member
Re: I'm having trouble creating Type's in VBA
 Originally Posted by Static
are u trying to access the Type outside of the class module??
it seems that way since its under cmdCreate....
put it in a reg bas module.. and declare it as Public
that's what i tried at first. and it said i the type wasn't recognized!
so i made a class module and ran it, and it recognized the type but said the the .datehired couldn't be found
-
Apr 27th, 2006, 10:18 AM
#8
Thread Starter
Lively Member
Re: I'm having trouble creating Type's in VBA
uhhhhhh,thanks static. it worked, lmao.
i guess i had it as private in the regular module
sorry dudes
-
Apr 27th, 2006, 10:34 AM
#9
Re: I'm having trouble creating Type's in VBA
glad it was an easy one... wasnt makin sense till I saw that.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|