Using a varable for an field name

Results 1 to 2 of 2

Thread: Using a varable for an field name

  1. #1
    Join Date
    Dec 1969

    Default Using a varable for an field name

    I am trying to pull up info from a field and I have the field name stored in a variable because it changes from time to time depending on the link you choose from the preceeding page and I don't know how to put it into the RecordSet(insertfieldnamehere) or if it is possible. Ideas??

  2. #2
    Join Date
    Dec 1969

    Default RE: Using a varable for an field name

    &#060;%<BR>fieldName = Request("userRequestedFormField")<BR>...<BR>Respon se.Write RS(fieldName)<BR>%&#062;<BR><BR>There is nothing magic here. You can access the RecordSet collection with *any* string expression. It doesn&#039;t have to be a string literal.<BR><BR>Heck you can do things like:<BR><BR>&#060;%<BR>fieldSuffix = Request("userRequestedFormFieldSuffix")<BR>...<BR> Response.Write RS("somePrefix" & fieldSuffix)<BR>%&#062;<BR><BR>or, branching out more exotic:<BR><BR>&#060;%<BR>x = Request("XXX")<BR>...<BR>Response.Write RS( "Q3L" & Left( RS(x), 4 )& "_zz" )<BR>%&#062;<BR><BR>[using one field requested by a user to then help find another field]<BR><BR><BR>Again, demonstrating that *any* string expression can be used.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts