Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
Problem with filter returning a zero record count |
Sat, Dec 30 2006 11:46 PM | Permanent Link |
"Kerry Cain" | I have a problem with a filter returning a zero record count - I know it is
not and can show it is so by using part of the code in a different manner. (see code below) Basically I am reading a list of field values from a listbox and applying them along with a start and finish date. At the moment I have a listbox with 4 values and I get results for 3 OK but not for 1 Code is as follows - procedure TfrmMain.BitBtn2Click(Sender: TObject); var Page: TfrxReportPage; Memo: TfrxMemoView; i, j, CurrIndex, LastIndex: integer; ProdName: string; Net, GST: double; function inches(val:integer):double; begin result:=(val/screen.pixelsperinch); end; begin frxReport1.Clear; Page := TfrxReportPage.Create(frxReport1); Page.CreateUniqueName; Page.SetDefaults; // now create product names form to get values from listbox frmProduct := TfrmProduct.Create (Application); frmProduct.Visible := false; // set starting values for memos in report lbName.Left := 3; lbName.Top := 5; lbAmt.Left := lbName.Left + lbName.Width + 3; lbAmt.Top := 5; lbName.Caption := ProdName; lbAmt.Caption := MyFormatFloat(Net); // iterate thru listbox and calculate totals for each value from database with frmProduct.ListBox1 do begin CurrIndex := 0 ; LastIndex := Items.count; repeat with frmProduct.ListBox1 do begin ProdName := Items[CurrIndex]; dbExpend.Filter := 'Date >= ' + QuotedStr(AnsiDateToStr(SDate))+ 'and Date <= ' + QuotedStr(AnsiDateToStr(FDate)) + 'and Product = ' + QuotedStr(ProdName); dbExpend.FilterOptions := []; dbExpend.Filtered := True; dbExpend.First ; // do database work here for j := 0 to dbExpend.RecordCount -1 do begin Net := Net + dbExpendNetAmt.Value; dbExpend.Next ; end; //set names of values here lbName.Caption := ProdName; lbAmt.caption := MyFormatFloat(Net); // write the names and values to the page memo:=draw_memo_inches(page,inches(lbName.left),inches(lbName.top),inches(lbName.width),inches(lbName.height),lbName); memo:=draw_memo_inches(page,inches(lbAmt.left),inches(lbAmt.top),inches(lbAmt.width),inches(lbAmt.height),lbAmt); Currindex := Currindex + 1; // increase listbox index and memo spacing on page lbName.Top := lbName.Top + 30; lbAmt.Top := lbName.Top ; //set product value to 0 Net := 0; // clear filter dbExpend.Filtered := false; dbExpend.Filter := ''; end; until Currindex = LastIndex; // repeat for all values end; //with frxReport1.showreport; end; ********************** use the following and record count = 3 *************** procedure TfrmMain.BitBtn3Click(Sender: TObject); begin dbExpend.Filter :='Product = ' + QuotedStr('Tax Payment'); dbExpend.FilterOptions := []; dbExpend.Filtered := True; dbExpend.First ; end; Actual Listbox items are Leather Hardware Thread Tax Payment Actual table fields are object dbExpendDate: TDateField DisplayWidth = 10 FieldName = 'Date' Origin = 'Expenditure.Date' Required = True end object dbExpendChequeNo: TStringField DisplayLabel = 'Cheque No' DisplayWidth = 10 FieldName = 'ChequeNo' Origin = 'Expenditure.ChequeNo' Size = 10 end object dbExpendSplit: TStringField DisplayLabel = 'Split?' DisplayWidth = 1 FieldName = 'Split' Origin = 'Expenditure.Split' Size = 1 end object dbExpendNetAmt: TFloatField DisplayLabel = 'Net Amt$' DisplayWidth = 10 FieldName = 'NetAmt' Origin = 'Expenditure.NetAmt' Required = True end object dbExpendGSTAmt: TFloatField DisplayLabel = 'GST Amt$' DisplayWidth = 10 FieldName = 'GSTAmt' Origin = 'Expenditure.GSTAmt' end object dbExpendTransType: TStringField DisplayLabel = 'Trans Type' DisplayWidth = 12 FieldName = 'TransType' Origin = 'Expenditure.TransType' Required = True Size = 12 end object dbExpendSupplier: TStringField DisplayWidth = 50 FieldName = 'Supplier' Origin = 'Expenditure.Supplier' Required = True Size = 50 end object dbExpendProduct: TStringField DisplayWidth = 50 FieldName = 'Product' Origin = 'Expenditure.Product' Required = True Size = 50 end object dbExpendKey: TAutoIncField DisplayWidth = 10 FieldName = 'Key' Origin = 'Expenditure.Key' Required = True Visible = False end For the life of me I can't see why this would work for three instead of all names. I would have thought that it would either work or not - I'm beat. I am using Delphi 5 and DBISAM 3.19 and would appreciate any advice Thanks Kerry |
Sun, Dec 31 2006 2:19 AM | Permanent Link |
"Ralf Bieber" | Kerry Cain wrote:
He Kerry > dbExpend.First ; > // do database work here > for j := 0 to dbExpend.RecordCount -1 do > begin > Net := Net + dbExpendNetAmt.Value; > dbExpend.Next ; > end; test this: dbExpend.First; // do database work here while not dbExpend.eof do begin Net := Net + dbExpendNetAmt.Value; dbExpend.Next ; end; Happy new year Ralf -- |
Sun, Dec 31 2006 4:20 AM | Permanent Link |
"Kerry Cain" | Thanks anyway. Don't know what was happening but suddenly everything is
working properly. Kerry |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |