Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a user defined type

Status
Not open for further replies.

uthomsst

MIS
Sep 18, 2001
15
GB
I am writing some code where I want to reference a user defined type via a fieldname which is held in a variable.

Does anyone know how to do this i.e.

Type TestType
desc as string
code as string
End Type

Dim FldName as String
Dim AUDT as TestType

FldName = "desc"

[AUDT.FldName] = "Description"


instead of

AUDT.desc = "Description"



Any Ideas????


 
You will have to explain that better because that makes no logical sense.
 
I have a user defined type there are 50 fields in it. I am writing a piece of code which will use an array of field names to access the fields in the user defined type. I am using the userdefined type to pass a record from a recordset between various functions, the screen and a recordset.

I don't want to type every time rst!xxx = type!xxx etc etc I want to have a loop that does it for me.

Here is the code I had to blank off the array

Dim STlData As SEF3BlkQltData

Select Case STLQltDataStructure(intIndex).FieldType
Case "String"
Let [STlData]![STLQltDataStructure(intIndex).FieldName] = ""
Case "Number"
Let [STlData.STLQltDataStructure(intIndex).FieldName] = 0
Case "Boolean"
Let [STlData.STLQltDataStructure(intIndex).FieldName] = False
Case "Date"
'Let [STlData.STLQltDataStructure(intIndex).FieldName] = NullDate()
End Select


STLQltDataStructure is the array that holds the field names and types.

I have tried lots of different ways to address the fields.
 
Code:
I am using the userdefined type to pass a record from a recordset between various functions
Why would you not just pass the record in a recordset?
 
Can you pass a recordset between forms and functions. I've always used user defined types. I have one routine that handles everything from all forms/functions etc.
 
Maybe I do not understand the question, but of course you can. A recordset is an object like any other object. However, not sure what you want to do with it once you pass it? If you are just reading the values then no problem. If you want to modify the values in the object, but not modify the real recordset then you will have to do a real "clone". But this way you know everything. The field type, the field name, the field value, etc. Just make a recordset from a query returning a single record and the needed fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top