Susan Harkins
ssharkins at bellsouth.net
Sat Jan 24 13:32:11 CST 2004
I considered that, but was trying to avoid DAO -- I should've mentioned
that -- I apologize. I'm using ADO -- and looping through the recordset
doesn't really require anymore code than the DAO querydef -- if I'm not
mistaken, ADO doesn't use the QueryDef object.
But, on the other hand, you don't have to create a Recordset using your
code.
Thanks Gustav.
Susan H.
> Hi Susan
>
> > I'm trying to return a field's data type.
>
> > I have the field by name -- as a string -- and I just can't seem to get
it
> > into a Field object variable so I can tap into the Type property. The
field
> > is the result of a listbox selection.
>
> > varField = lstField.Value
>
> > How can I get from there to
>
> > fld = varField
>
> > to here
>
> > varType = fld.Type
>
> > Everything I've tried returns an Object required at the fld=varField
> > statement because varField is a string, not a real reference. At least,
I
> > think that's the problem.
>
> Something like this? If the rowsource is an SQL string:
>
> Dim dbs As Database
> Dim qdf As QueryDef
> dim intVarType As Integer
>
> Set dbs = CurrentDb()
> Set qdf = dbs.CreateQueryDef(vbNullString)
> qdf.SQL = Me!lstDemo.RowSource
>
> intVarType = qdf.Fields("YourFieldName").Type
> Debug.Print intVarType
>
> qdf.Close
>
> Set qdf = Nothing
> Set dbs = Nothing
>
> If not an SQL string, just pick the name of the stored query and use
> that as qdf.
>
> /gustav
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>