Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    Asheboro
    Posts
    7

    Question Unanswered: Macro Substitution

    I am trying to find a way to combine a variable and the element of a For statement to determine the variable that will hold a value.
    This is hard to explain but I am sure that someone has done this kind of thing before. I know in Visual Foxpro you can use the Macro Substitution Command '&' to accomplish the same kind of thing and shorten the code that will need to be written drastically.

    My Example:
    Dim lcVariable1 as String, lcVarable2 as String, i as integer

    For i = 1 to 2
    lcVariable + trim(str(i)) = Me("cmbField" & i).value
    Next

    **Please note = The variable is where I have the problem.**
    I also would like to know if there is a better way to create the lcVariables. Can I use 'As Collection'. Access help doesn't explain collections very well in my opinion.

    Thanks in advance for your help!!!!
    Last edited by teswaney; 09-03-02 at 09:48.

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122

    Re: Macro Substitution

    Why don't you use an array?
    You'll get something like
    For i = 1 to 2
    lcVariable(Trim(str(i)) = Me("cmbField" & i).value
    Next

    Dan

    Originally posted by teswaney
    I am trying to find a way to combine a variable and the element of a For statement to determine the variable that will hold a value.
    This is hard to explain but I am sure that someone has done this kind of thing before. I know in Visual Foxpro you can use the Macro Substitution Command '&' to accomplish the same kind of thing and shorten the code that will need to be written drastically.

    My Example:
    Dim lcVariable1 as String, lcVarable2 as String, i as integer

    For i = 1 to 2
    lcVariable + trim(str(i)) = Me("cmbField" & i).value
    EndFor

    **Please note = The variable is where I have the problem.**
    I also would like to know if there is a better way to create the lcVariables. Can I use 'As Collection'. Access help doesn't explain collections very well in my opinion.

    Thanks in advance for your help!!!!

Posting Permissions

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