|
-
Aug 1st, 2006, 09:05 AM
#1
Thread Starter
Lively Member
[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
-
Aug 1st, 2006, 09:31 AM
#2
Thread Starter
Lively Member
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
-
Aug 1st, 2006, 09:39 AM
#3
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:
Private Sub Combo1_Click()
DBList1.ListField = Replace(Combo1.List(Combo1.ListIndex), " ", "_")
End Sub
-
Aug 1st, 2006, 09:41 AM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|