Skip to Content
avatar image
Former Member

2 Conditions in a Query

Hi to all:

I Got an error when i execute: oDBDataSource1.Query oConditions

I can't instert two conditions??, with only one work's perfectly but when I insert a second group of condtions, I got a problem.

Here is the code:

Public Sub SetMatrix1(lproy As Integer)

Dim oConditions As SAPbouiCOM.Conditions

Dim oCondition As SAPbouiCOM.Condition

Dim i As Long

Dim oMatrix As SAPbouiCOM.Matrix

Set oConditions = New SAPbouiCOM.Conditions

Set oMatrix = oForm.Items.Item("Matrix1").Specific

Set oCondition = oConditions.Add

oCondition.BracketOpenNum = 1

oCondition.Alias = "U_usuario"

oCondition.Operation = co_EQUAL

oCondition.CondVal = lusuario

oCondition.BracketCloseNum = 1

oCondition.Relationship = cr_AND

oCondition.BracketOpenNum = 2

oCondition.Alias = "U_proyecto"

oCondition.Operation = co_EQUAL

oCondition.CondVal = lproy

oCondition.BracketCloseNum = 2

oDBDataSource.Query oConditions

oMatrix.Clear

Dim oBtn As SAPbouiCOM.Button

Dim oItem As SAPbouiCOM.Item

For i = 0 To oDBDataSource.Size - 1

oDBDataSource.Offset = i

' oUserDataSource1.Value = i + 1

oMatrix.AddRow

Next i

oMatrix.AutoResizeColumns

End Sub

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 21, 2004 at 04:13 PM

    I haven't tried the code so I can't be sure, but my guess would be you need to add another condition to your Queries conditions collection.

    Between the lines

    <i>oCondition.Relationship = cr_AND

    oCondition.BracketOpenNum = 2</i>

    Try adding:

    <i>Set oCondition = oConditions.Add</i>

    So your code should be:

    <i>Public Sub SetMatrix1(lproy As Integer)

    Dim oConditions As SAPbouiCOM.Conditions

    Dim oCondition As SAPbouiCOM.Condition

    Dim i As Long

    Dim oMatrix As SAPbouiCOM.Matrix

    Set oConditions = New SAPbouiCOM.Conditions

    Set oMatrix = oForm.Items.Item("Matrix1").Specific

    Set oCondition = oConditions.Add

    oCondition.BracketOpenNum = 1

    oCondition.Alias = "U_usuario"

    oCondition.Operation = co_EQUAL

    oCondition.CondVal = lusuario

    oCondition.BracketCloseNum = 1

    oCondition.Relationship = cr_AND

    Set oCondition = oConditions.Add

    oCondition.BracketOpenNum = 2

    oCondition.Alias = "U_proyecto"

    oCondition.Operation = co_EQUAL

    oCondition.CondVal = lproy

    oCondition.BracketCloseNum = 2

    oDBDataSource.Query oConditions

    oMatrix.Clear

    Dim oBtn As SAPbouiCOM.Button

    Dim oItem As SAPbouiCOM.Item

    For i = 0 To oDBDataSource.Size - 1

    oDBDataSource.Offset = i

    ' oUserDataSource1.Value = i + 1

    oMatrix.AddRow

    Next i

    oMatrix.AutoResizeColumns

    End Sub</i>

    Hope this helps

    Add comment
    10|10000 characters needed characters exceeded