Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.