hi,

i used the following coding prior to report generation.

VB Code:
  1. d.Execute ("delete from rep_prd")
  2. d.Execute ("delete from rep_others")
  3. d.Execute ("delete from rep_fandr")
  4. d.Execute ("delete from rep_vat")
  5.  
  6. Set rs1 = d.Execute("select no as invno from inv_mast where no between '" + Text2 + "' and '" + Text3 + "'")
  7.  
  8. If rs1.EOF Then
  9. MsgBox "No Invoice between the Specified Range", vbOKOnly + vbCritical, "Warning !!"
  10. Text1 = ""
  11. Text2 = ""
  12. Text3 = ""
  13. Text1.SetFocus
  14. Exit Sub
  15. Else
  16.  
  17. Set rs2 = d.Execute("select * from inv where no between '" + Text2 + "' and '" + Text3 + "' order by line")
  18.  
  19. Do While Not rs2.EOF
  20.  
  21.     MsgBox rs2!code, , "Code"
  22.    
  23.     If Len(rs2!code) = 8 Then
  24.         c1 = Mid(rs2!code, 1, 2)
  25.         Set rs4 = d.Execute("select des from glob where no='" + c1 + "'")
  26.         If Not rs4.EOF Then
  27.             d1 = rs4!des
  28.         End If
  29.         rs4.Close
  30.         c2 = Mid(rs2!code, 3)
  31.         Set rs3 = d.Execute("insert into rep_prd values('" + invno + "','" + c1 + "','" + d1 + "','" + c2 + "','" + rs2!des + "','" + rs2!qty + "','" + rs2!Rate + "','" + rs2!amt + "')")
  32.     End If
  33.    
  34.     If Len(rs2!code) = 2 And rs2!code <> 95 And rs2!code <> 99 And rs2!code <> 72 Then
  35.             c3 = rs2!code
  36.             Set rs4 = d.Execute("select des from glob where no='" + c3 + "'")
  37.             If Not rs4.EOF Then
  38.                 d2 = rs4!des + " ON  Rs." + rs2!qty + " @ " + rs2!Rate + "%"
  39.             End If
  40.             rs4.Close
  41.             Set rs3 = d.Execute("insert into rep_others values('" + invno + "','" + c3 + "','" + d2 + "'," + rs2!amt + ")")
  42.     End If
  43.    
  44.     If Len(rs2!code) = 2 And rs2!code = 72 Then
  45.         c3 = rs2!code
  46.         Set rs4 = d.Execute("select des from glob where no='" + c3 + "'")
  47.         If Not rs4.EOF Then
  48.             d2 = rs4!des + " ON  Rs." + rs2!qty + " @ " + rs2!Rate + "%"
  49.         End If
  50.         rs4.Close
  51.         Set rs3 = d.Execute("insert into rep_vat values('" + invno + "','" + c3 + "','" + d2 + "'," + rs2!amt + ")")
  52.     End If
  53.    
  54.     If Len(rs2!code) = 2 And rs2!code = 95 Or rs2!code = 99 Then
  55.         c3 = rs2!code
  56.         Set rs4 = d.Execute("select des from glob where no='" + c3 + "'")
  57.         If Not rs4.EOF Then
  58.             d2 = rs4!des
  59.         End If
  60.         rs4.Close
  61.         Set rs3 = d.Execute("insert into rep_fandr values('" + invno + "','" + c3 + "','" + d2 + "'," + rs2!amt + ")")
  62.     End If
  63.  
  64. rs2.MoveNext
  65. Loop
  66. End If
  67. 'Else
  68. 'MsgBox "No Products Sold"
  69. 'End If 'rs2 close
  70. 'End If 'rs1 close
  71.  
  72. inv.ReportFileName = App.Path & "\inv.rpt"
  73. inv.WindowState = crptMaximized
  74. inv.DiscardSavedData = 1
  75. inv.Action = 1

there is no error in adding to the corresponding table.
but while generating reports, i face some problems :

1) invno is always retrieved as blank with no values stored in it.

2)Now as i am giving both values Text2 and Text3 same, i am able to get the product list correctly. bt when i giv a range of values, hw shud i change the looping structure so that for each invoice(that i get thru range), i get reports separetly.

3)in the table rep_others and rep_fandr, i will hav multiple fields. while adding to the table i hav added correctly, bt while displaying iam able to view only 1 row. y is it so? [NOTE:For rep_prd table i hav include subtotal field. so im unable to include it in the "Details" part.

plz help me solve this...................