Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49

    Unanswered: if # or # or # or # or # = "2" then

    Hey all,

    Like the title says:

    if # or # or # or # or # = "2" then

    how would I write that? I have seven fields that I am using. This is a after update event.

    I have not been able to write a "if 'variable' or 'variable' then" statement and get it to work.

    Any info & suggestions is greatly appreciated.

    Thanks very much.

    I am in a time crunch with the boss.

    Richard.

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    uh ...

    If (#="2") or (#="2") or ... then ' Continue adding conditions until done

    Why are you testing against a string? is the "#" a string also?
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    Sub TestFiniteParamsLooper()
     
        If FiniteParamsLooper(2, 1, 2, 3, 5) = True Then
        
            MsgBox "It's in there"
        
        End If
     
    End Sub
     
    Function FiniteParamsLooper(ValToFind As Variant, ParamArray InThese() As Variant) As Boolean
        Dim Valerant As Variant
        
        For Each Valerant In InThese()
            
            If Valerant = ValToFind Then
                FiniteParamsLooper = True
                Exit For
            End If
            
        Next Valerant
        
    End Function
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    can you dumb that down a bit for me.

    I have 7 fields that can 3 differnt values (1, 2, 3) and if all of the values is 2 then txtstatus will = in process.

    if all of the 7 values = 3 then txtstatus will = complete

    else txtstatus will = in process.

    now if 6 of the 7 values = 6 and one value = 2 then txtstatus = in process.

    if all values are null then txtstatus = not started.

    Richard.

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I thought you said they can only have 1, 2 or 3 for possible values? Where did "values = 6" come from?

    Maybe you can do what you want with a bitmask, I'm still a little hazy on how this UI is really supposed to work though...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    Aug 2004
    Location
    Cinci, OH
    Posts
    49
    that should read:

    now if 6 of the 7 values = "3" and one value = 2 then txtstatus = in process

    sorry.

    Richard.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    Sub TestFiniteParamsLooper()
     
        If FiniteParamsLooper(2, False, Null, Null, Null, Null) = True Then
            
            MsgBox "Not started!"
            
        ElseIf FiniteParamsLooper(2, False, 3, 3, 3, 3, 3) = True Then
        
            MsgBox "Complete!"
        
        Else
        
            MsgBox "In process!"
            
        End If
     
    End Sub
     
    Function FiniteParamsLooper(ValToFind As Variant, IsAnOr As Boolean, ParamArray InThese() As Variant) As Boolean
        
        Dim Valerant As Variant
        
        FiniteParamsLooper = Not IsAnOr
        
        For Each Valerant In InThese()
            
            If (Valerant = ValToFind) = IsAnOr Then
                FiniteParamsLooper = IsAnOr
                Exit For
            End If
            
        Next Valerant
        
    End Function
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I would do this with a bitmask. Assign each value of your controls a bit value that you can assemble at the end, then use bitwise operators to determine whether it matches any of your requisite patterns.

    Ie:
    control1 value list - (1, 2, 4)
    control2 value list - (8, 16, 32)
    control3 value list - (64, 128, 256)

    Then when it comes to eval time, add them all up:

    lngYourVar = control1.value + control2.value + control3.value

    Now you can evaluate that lng value against whatever patterns need to match, for example:

    Lets say all three controls have to have the third value selected, so add those all up:

    4 + 32 + 256 = 292

    Now use the bitwise AND with 292 against your bitmask to see if they have met the required pattern:

    If (lngYourVal AND 292) = 292 Then
    'All controls set to third value
    End If
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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