Solved

How to clear the values in udt's

Posted on 2014-09-22
7
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 47

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 47

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 47

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 47

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

739 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