none
For loop on textboxes in Access RRS feed

  • Question

  • Hi,

    I have a form which has textboxes with names "Text0 to Text511" (auto created in access). I have a module to enter values for each text box in the form. However, the module has 512 line coding with the same line as below except for the change in the textbox name.

    Ex: text0.value = dsum("ID","DataDump","Date1=combo0.value and ID <>'' ")

    Is there any changes of writing a one liner coding with a for loop in this case?

    Wednesday, December 23, 2015 9:27 AM

Answers

  • I have a form which has textboxes with names "Text0 to Text511" (auto created in access). I have a module to enter values for each text box in the form. However, the module has 512 line coding with the same line as below except for the change in the textbox name.

    Ex: text0.value = dsum("ID","DataDump","Date1=combo0.value and ID <>'' ")

    Hi Dileep,

    You could use something like:

    For x = 0 To 511
    Me("Text" & x) = DSum ("ID","DataDump",<yourcondition>) Next

    Imb.

    • Proposed as answer by David_JunFeng Thursday, December 24, 2015 5:34 AM
    • Marked as answer by David_JunFeng Tuesday, January 5, 2016 1:33 AM
    Wednesday, December 23, 2015 9:45 AM

All replies

  • I have a form which has textboxes with names "Text0 to Text511" (auto created in access). I have a module to enter values for each text box in the form. However, the module has 512 line coding with the same line as below except for the change in the textbox name.

    Ex: text0.value = dsum("ID","DataDump","Date1=combo0.value and ID <>'' ")

    Hi Dileep,

    You could use something like:

    For x = 0 To 511
    Me("Text" & x) = DSum ("ID","DataDump",<yourcondition>) Next

    Imb.

    • Proposed as answer by David_JunFeng Thursday, December 24, 2015 5:34 AM
    • Marked as answer by David_JunFeng Tuesday, January 5, 2016 1:33 AM
    Wednesday, December 23, 2015 9:45 AM
  • Awesome!!! You made my job easier... Appreciate your timely response.. KUDOS!!!
    Wednesday, December 23, 2015 10:02 AM