Results 1 to 4 of 4

Thread: [RESOLVED] Only show the selected record

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    106

    Resolved [RESOLVED] Only show the selected record

    Im using visual basic 6, Access, ADO and Crystal Report.

    I have to records in the database and when i select one it shows both, how can i only show the selected record?
    This is my code im listing with dblist:



    Private Sub cmdPreview_Click()
    CrystalReport1.PrintReport
    End Sub

    Private Sub cmdProdutos_Click()
    frmListFact.Hide
    frmADOFacObras.Show
    End Sub

    Private Sub cmdSair_Click()
    Unload Me
    frmMenuSel.Show
    End Sub

    Private Sub Combo1_Click()

    Select Case Combo1.ListIndex
    Case 0
    DBList1.ListField = "Id_Factura"
    Case 1
    DBList1.ListField = "Data"
    Case 2
    DBList1.ListField = "Data_Vencim"
    Case 3
    DBList1.ListField = "Cliente"
    Case 4
    DBList1.ListField = "Descricao"
    Case 5
    DBList1.ListField = "Desconto"
    Case 6
    DBList1.ListField = "IVA"
    Case 7
    DBList1.ListField = "Valor_Liquido"
    Case 8
    DBList1.ListField = "Base_do_IVA"
    Case 9
    DBList1.ListField = "Valor_Desconto"
    Case 10
    DBList1.ListField = "Total_Factura"

    End Select

    End Sub



    Private Sub DBList1_Click()

    Data1.Recordset.Bookmark = DBList1.SelectedItem

    End Sub

    Private Sub Form_Load()

    Combo1.AddItem "Id Factura"
    Combo1.AddItem "Data"
    Combo1.AddItem "Data Vencim"
    Combo1.AddItem "Cliente"
    Combo1.AddItem "Descricao"
    Combo1.AddItem "Desconto"
    Combo1.AddItem "IVA"
    Combo1.AddItem "Valor Liquido"
    Combo1.AddItem "Base do IVA"
    Combo1.AddItem "Valor Desconto"
    Combo1.AddItem "Total Factura"

    End Sub

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    106

    Re: Only show the selected record

    This piece of code was missing:

    Dim Formula As String

    Formula = "{Facturas.Id_Factura} =" & Val(lblFact.Caption)
    CrystalReport1.SelectionFormula = Formula

    Problem solved

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Only show the selected record

    Good stuff, thanks for sharing the answer.

    By the way, you can reduce the code of Combo1_Click a bit (assuming the only difference in the items is that each space is replaced by _):
    VB Code:
    1. Private Sub Combo1_Click()
    2.  
    3.   DBList1.ListField = Replace(Combo1.List(Combo1.ListIndex), " ", "_")
    4.  
    5. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2006
    Posts
    106

    Re: [RESOLVED] Only show the selected record

    Thanks mate

    I posted the answer bacause that way others can solve problems like mine.

Posting Permissions

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



Click Here to Expand Forum to Full Width