Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT field1 WHERE field2 = something

Status
Not open for further replies.

MrsMope987

Programmer
Sep 27, 2007
23
Hello,
I am a complete novice at Crystal Reports this is my first attempt. I have created a VB.NET application that creates a XML Datasource in the following format:

Code:
<OrderInfo>
    <TabIndex>0</TabIndex>
    <FieldName>GroupBox9</FieldName>
    <FieldValue>New Order</FieldValue>
  </OrderInfo>
and I want the report to look like an order form with each of the fields from the form filled in appropriately with the values, but I can't figure out how to do it.

If I were going to do this from SQL it would be
Code:
SELECT FieldValue FROM OrderInfo WHERE FieldName = 'GroupBox9'

What is the correct syntax for that statement in Crystal?

Thanks,
 
If you want the entire report to be based on "GroupBox9" then, you would go to report->selection formula->record and enter:

{OrderInfo.FieldName} = 'GroupBox9'

If you want this just for a particular "field" display, create a conditional formula in the field explorer->formula->new:

if {OrderInfo.FieldName} = 'GroupBox9' then
{OrderInfo.FieldValue}

You would place this in the detail section.

-LB

 
That helps me on some of the other fields that I have but not this one in particular.

GroupBox9 contains three radio buttons each with a different text value. I want the text value displayed in the report field. Is there a way to do that? Or do I need to change my code?
this is the code that creates the XML Dataset;
Code:
 For Each ctl As Control In Controls
            If TypeOf ctl Is Panel Then
                If ctl.Name = pnl.Name Then
                    str(0) = "999"
                    str(1) = ctl.Name.ToString
                    str(2) = ctl.Text
                    ds.Tables("OrderInfo").Rows.Add(str)
                    For Each subCtl As Control In CType(pnl, Panel).Controls
                        If TypeOf subCtl Is Label Or _
                            TypeOf subCtl Is GroupBox Or _
                            TypeOf subCtl Is DataGrid Or _
                            TypeOf subCtl Is Button Or _
                            TypeOf subCtl Is DataGrid Or _
                            TypeOf subCtl Is Panel Then
                        Else
                            str(0) = subCtl.TabIndex
                            str(1) = subCtl.Name.ToString

                            str(2) = subCtl.Text

                            ds.Tables("OrderInfo").Rows.Add(str)
                        End If

                    Next
                Else
                End If
            ElseIf TypeOf ctl Is Label Or _
                    TypeOf ctl Is DataGrid Or _
                    TypeOf ctl Is Button Then
                'ignore this item
            ElseIf TypeOf ctl Is GroupBox Then
                For Each grpctl As Control In CType(ctl, GroupBox).Controls
                    If TypeOf grpctl Is RadioButton Then
                        If CType(grpctl, RadioButton).Checked = True Then
                            str(0) = grpctl.TabIndex
                            str(1) = ctl.Name.ToString
                            str(2) = grpctl.Text
                            ds.Tables("OrderInfo").Rows.Add(str)
                        End If
                    ElseIf TypeOf grpctl Is CheckBox Then
                        If CType(grpctl, CheckBox).Checked = True Then
                            str(0) = grpctl.TabIndex
                            str(1) = ctl.Name.ToString
                            str(2) = grpctl.Text
                            ds.Tables("OrderInfo").Rows.Add(str)
                        End If
                    End If

                Next
            Else
                str(0) = ctl.TabIndex
                str(1) = ctl.Name.ToString
                str(2) = ctl.Text
                ds.Tables("OrderInfo").Rows.Add(str)
            End If
        Next
        DataGridView1.Sort(DataGridView1.Columns(0), System.ComponentModel.ListSortDirection.Ascending)

        ds.WriteXml("C:\dataset.xml", XmlWriteMode.WriteSchema)
    End Sub

 
Sorry, I'm not familiar with this type of code.

-LB
 
Doesn't matter really it is VB, I just need to know if there is a way in Crystal reports to do ;
Select fieldvalue where fieldname = groupbox9

because the if statement you gave me won't work i don't think. I want to always display the fieldvalue for fieldname groupbox9.

Code:
table info:
TabIndex             FieldName         FieldValue
1                    GroupBox9         Mesh
2                    dtpOrderDate      10/08/2007
3                    dtpDelDate        11/11/2007

So for the above three records I would want to have three fields on the report to show the FieldValue based on the FieldName. I hope that explains a little better.
 
To help explain it better think of the SQL statement as being split in two parts.

Instead of: SELECT FieldValue FROM OrderInfo WHERE FieldName = 'GroupBox9'

Crystal first selects the appropriate records:

//Place in selection criteria

{orderinfo.fieldName} = 'GroupBox9'


and then you choose any information you wish to display for the records retreived which match your selection criteria. This is why the linking of tables becomes important so as to retreive the data correctly.

As a basic example you might choose to add the database field {orderinfo.fieldvalue} to the detail section of the report.

An example of what you are seeing now compared to what you want to see helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top