Solved

How to clear the values in udt's

Posted on 2014-09-22
7
128 Views
Last Modified: 2014-09-22
I udts that i need to use over with new data
how do i clear the data in the udt's ?


Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type

Private Type Recap_UDT
  CompanyName  As Byte
  Estimator    As Byte
  sDate        As Byte
  BidAmount    As Byte
  BidMaterial  As Byte
  Bid2Amount   As Byte
  Bid2Material As Byte
  sqs          As Byte
  BusYrs       As Byte
   TempNotUsed   As Byte ' for future use if needed
End Type

Private Type Phone_UDT
  Cell      As String
  Office    As String
  Emergency As String
  Fax       As String
  Owner     As String
  LasrRow   As String
  TempNotUsed   As String ' for future use if needed
End Type

Private Type Task_UDT
  DaysComplete         As String
  ReceivedWork         As String
  ReceivedPLPD         As String
  CompanySubContractor As String
  ReceivedSubWork      As String
  ReceivedSubPLPD      As String
  FutureUse            As String 'not used
   TempNotUsed        As String ' for future use if needed
End Type

Private Type RoofCompany_UDT
  CompanyName  As String
  Address      As String
  City         As String
  State        As String
  Zip          As String
  sqs          As String
  BidAmount    As String
  BidMaterial  As String
  Bid2Amount   As String
  Bid2Material As String
  sDate        As String
  BusYrs       As String
  Estimator    As String
  Email        As String
  Notes        As String
  TempNotUsed  As String ' for future use if needed
  Phones       As Phone_UDT
  Tasks        As Task_UDT
End Type

Private RoofCompany() As RoofCompany_UDT

Open in new window

0
Comment
Question by:isnoend2001
  • 4
  • 3
7 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40336895
There's no need to clear them. Think of them as just another type of variable like a String. In that case of course you know that you don't have to do this

Dim strTemp As String

strTemp = "Old"
strTemp = ""
strTemp = "New"

Open in new window


And so you don't have to do it with your UDTs either.
0
 

Author Closing Comment

by:isnoend2001
ID: 40336945
Thanks good to know
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40336992
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:isnoend2001
ID: 40337010
i think this may not work What if:
The first time the udt is used 10 of the fields are used
The 2nd time only 5 field are overwritten
would this not leave the old data ? in some of the fields
only the first field is required to save(CompanyName)
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40337072
Again it's just like the situation with a String. If the string is locally defined as in a Sub or Function, that string is automatically initialized each time the Sub or Function is run. So if you do this you don't have to worry about it

Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type

Private Sub Test
Dim IU As Info_UDT

Msgbox IU.CompanyName '<---- will always display a blank
IU.CompanyName = "Apple"
End Sub

Open in new window


However here you would have to manually initialize the unchanged portions of the UDT

Private Type Info_UDT
  CompanyName  As Byte
  Address      As Byte
  sDate        As Byte
  City         As Byte
  State        As Byte
  Zip          As Byte
  Estimator    As Byte
  BidAmount    As Byte
  sqs          As Byte
  BidMaterial  As Byte
  Email        As Byte
  Bid2Material As Byte
  Bid2Amount   As Byte
  BusYrs       As Byte
  TempNotUsed   As Byte ' for future use if needed
End Type
Private IU As Info_UDT

Private Sub Test

Msgbox IU.CompanyName '<---- will display a blank the first time but "Apple" after that unless changed
IU.CompanyName = "Apple"
End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40337086
In the second situation you could create a Sub like this one and call it when you need to. (BTW why do you use Byte?)

Private Sub Init()
 IU.CompanyName = ""
  IU.Address  = ""
  IU.sDate  = ""
  IU.City  = ""
  IU.State  = ""
  IU.Zip  = ""
  IU.Estimator = ""
  IU.BidAmount  = ""
  IU.sqs  = ""
  IU.BidMaterial  = ""
  IU.Email  = ""
  IU.Bid2Material = ""
  IU.Bid2Amount  = ""
  IU.BusYrs  = ""
  IU.TempNotUsed  = ""
End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40337226
Thanks,
Don't know about byte, somebody else wrote the udts
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now