Creating a variable from an expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Blair

    Creating a variable from an expression

    I have a loop in a MS Access application of which I would like to
    number the variables within the database as follows:

    tbl
    rev1
    rev2
    rev3...

    I would like to do the following:

    for i=1 to 20
    rs![rev&i] = expression

    next

    The rs![rev&i] will not work??????

    Please help!
  • MacDermott

    #2
    Re: Creating a variable from an expression

    You could try rs.Fields("rev" & i).

    But if you have multiple fields in a table which are so similar you want to
    give them numbered names and treat them similarly, I'd suggest that you
    consider normalizing your table design.

    HTH
    - Turtle

    "Mike Blair" <blairmc@prodig y.net> wrote in message
    news:49845629.0 408171347.6de3f f4f@posting.goo gle.com...[color=blue]
    > I have a loop in a MS Access application of which I would like to
    > number the variables within the database as follows:
    >
    > tbl
    > rev1
    > rev2
    > rev3...
    >
    > I would like to do the following:
    >
    > for i=1 to 20
    > rs![rev&i] = expression
    >
    > next
    >
    > The rs![rev&i] will not work??????
    >
    > Please help![/color]


    Comment

    • Hank Reed

      #3
      Re: Creating a variable from an expression

      "> "Mike Blair" <blairmc@prodig y.net> wrote in message[color=blue]
      > news:49845629.0 408171347.6de3f f4f@posting.goo gle.com...[color=green]
      > > I have a loop in a MS Access application of which I would like to
      > > number the variables within the database as follows:
      > >
      > > tbl
      > > rev1
      > > rev2
      > > rev3...
      > >
      > > I would like to do the following:
      > >
      > > for i=1 to 20
      > > rs![rev&i] = expression
      > >
      > > next
      > >
      > > The rs![rev&i] will not work??????
      > >
      > > Please help![/color][/color]
      Mike,
      The correct syntax is: rs(rev & i) = expression
      Hank Reed

      Comment

      Working...