Click to See Complete Forum and Search --> : Database Variable Problems


tomjowitt
October 11th, 2001, 07:51 AM
i need to assign variables from a recordset called from an SQL statement but i can't figure out how to change the Field Name bit to a variable .... i've tried all sorts of bracket combinations, etc but to no avail. is this possible at all?

EG:

VarToBeAssigned = RstRecordSet![NeedToHaveVarInHere]

Andrew_Fryer
October 11th, 2001, 08:06 AM
Try:

VarToBeAssigned = RstRecordSet![<FIELD_NAME in database>]

Cimperiali
October 11th, 2001, 08:07 AM
are you looking for this?
dim varFieldName as string
varFieldName= "A_field_name"
varToBeAssigned= rsRecordset(varFieldName).value

Warning: the recordset maybe a null value, so
varToBeAssigned better be variant!

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

tomjowitt
October 11th, 2001, 08:12 AM
thanks a lot ... it was the .value bit that i was missing to sort that out