Charlotte Foust
cfoust at infostatsystems.com
Mon Jan 26 11:26:01 CST 2004
It doesn't matter whether you're using DAO or ADO, you need to use the Set keyword to instantiate an object like a field, and there's no way to using just the name of the field. Have you tried using the Type property of the field? Online help has an example of code to determine the type property using an ADO recordset opened on the table. Charlotte Foust -----Original Message----- From: Susan Harkins [mailto:ssharkins at bellsouth.net] Sent: Saturday, January 24, 2004 11:32 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] data type for field in a closed table 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 > _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com