variant field type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you assign the variant data type to a field??

Access 2003 help shows variant as the default data type. But it doesn't
even show up on my list when in design view i look at dropdown selections for
data type for a field.
 
"Variant" applies only in VBA code.
"Field" applies to a column of a table.
You cannot create a field of type Variant.

In VBA code, you can assign a variant's value to a field if it is a suitable
type. This example assumes a bound form with a text box named "Surname", and
code in the module of the form:

Dim varMyVariant As Variant
varMyVariant = "Smith"
Me.Surname = varMyVariant
 
My mistake I meant Data type for the field - not field type. the issue comes
up in the following use cases:

use case #1: I would like the field to be able to hold an array
use case #2: users may input a number or text

thanks
 
Case 2 is easy: use Text type. It can be alpha or numeric.

Case 1 is not appropriate for a field, because one of the basic rules of
data normalization is to store atomic data, i.e. do not put multiple items -
such as an array - in a table. Instead, create a related table, and store
the items one per row. The related table is the best equivalent to an array
(or actually to a structure.)
 
Thanks - making the adjustment from excel vba to access i missed the table as
an array concept.
 
Back
Top