Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2004
    Thanked 0 Times in 0 Posts

    referencing variables in a loop (Access 2000)

    I am having difficulty trying to find the right syntax to properly reference a variable in a loop. The problem I am having is that the variable I am trying to reference is from a form and I am in a report. Its an outside variable. Instead of typing this 20 times:
    If [Forms]![Query_Builder]![check1] Then
    If [Forms]![Query_Builder]![check2] Then
    If [Forms]![Query_Builder]![check3] Then
    I would like to type something like:
    Dim i As Integer
    For i = 1 To 20
    If ("[Forms]![Query_Builder]![Check" & i & "]") = 0 Then
    I don't know the exact syntax to make that work.
    I have done similiar loop/if statements with local variables. It looks like:
    For i = 1 To 20
    If Me("txt" & i) = 0 Then
    However, that is for [txt1] which is for a textbox inside the form.
    Does anyone know the correct syntax for referencing a checkbox in a form from a report?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: referencing variables in a loop (Access 2000)

    Welcome to Woody's Lounge! Try something like this:

    For i = 1 To 20
    If Forms!Query_Builder.Controls("Check" & i) = False Then
    End If
    Next i

    Instead of Forms!Query_Builder.Controls("Check" & i) you can also use Forms!Query_Builder("Check" & i)

Posting Permissions

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