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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in Using Multiple bill to Dot Matrix Printer

Status
Not open for further replies.

arna

Programmer
Sep 14, 2001
5
IN
Below is the code used for printing all the bill by pressing one command button .The problem is that it prints only one bill only and not all the bills .Kindly check the code and guide me.


Dim BB As Long
'// LOADING THE BILL NUMBER
SQL = ""

BB = 0

SQL = "SELECT MAX([BILLNO])AS RR FROM [bill] WHERE [bill_date] >= #" & D11 & "#" _
& &quot; AND [bill_date] <= #&quot; & D21 & &quot;#&quot; _
& &quot; AND [BName] = '&quot; & Trim(ttax.CONAME) & &quot;'&quot;

comm.CommandText = SQL
Set res = New Recordset
Set res = comm.Execute
' MsgBox (res.RecordCount), , &quot;The Recordcount &quot;
If (IsNumeric(res!rr) = False) Then
BB = 0
' MsgBox (BB), , &quot;The value of the Bill&quot;
End If

If (IsNumeric(res!rr) = True) Then
BB = res!rr
' MsgBox (BB), , &quot;The Current Value of the Bill&quot;
End If

'// LOADING BILL NUMBER OVER

With frmBill
For i = 0 To .Combo1.ListCount - 1
'MsgBox &quot;In the loop&quot;
'// THE ACTUAL CALCULATION FOR PRINTING THE BILL
tless = LESS(.Combo1.List(i))






' MsgBox (BB), , &quot;THE CURRENT BILL NUMBER&quot;
'// LOADING THE LIST TRANSACTION FOR THE GIVEN PERIOD OF DATE
SQL = &quot;SELECT * FROM [sales] WHERE [date] >= #&quot; & CDate(frmBill.MD.Text) & &quot; #&quot; _
& &quot; AND [date] <= #&quot; & CDate(frmBill.MD2.Text) & &quot;#&quot; _
& &quot; AND [CUname] = '&quot; & Trim(.Combo1.List(i)) & &quot;'&quot; _
& &quot; ORDER BY [date],[chall]&quot;

comm.CommandText = SQL
Set res = New Recordset
Set res = comm.Execute
If (res.RecordCount > 0) Then
BB = BB + 1 '// INCREASING THE BILL NUMBER
Call TAX
'// DELETING THE PREVIOUS DATA FROM THE PRINT DATABASE
SQL = &quot;DELETE FROM [print] &quot;
comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute

'// SAVING THE RECORDS INTO THE PRINT TABLE
If (res.BOF = False) Then
res.MoveFirst
End If
'SAVING THE RECORDS TO THE BILL
Do While res.EOF = False

SQL = &quot;UPDATE [sales] SET Rate = &quot; & colL1.Item(res!Dis) _
& &quot; WHERE [date] = #&quot; & res!date & &quot;#&quot; _
& &quot; AND [CUName] = '&quot; & Trim(.Combo1.List(i)) & &quot;'&quot; _
& &quot; AND [dis] = '&quot; & res!Dis & &quot;'&quot; _
& &quot; AND [chall] = &quot; & res!CHALL
comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute

If (res.EOF = True) Then
Exit Do
End If

res.MoveNext
Loop

res.MoveFirst
Do While res.EOF = False

SQL = &quot; INSERT INTO [print] ([BillNo],[BillDate],[name],[chall],[particulars],[nos],[rate],[total],[sal_tax],[ctax],[Form_Name],[Form_Number],[Other1],[Other2],[less],[surcharge],[words]) VALUES ( &quot; _
& BB & &quot;,&quot; _
& &quot;#&quot; & CDate(Me.Text3.Text) & &quot;#&quot; & &quot;,&quot; _
& &quot;'&quot; & Trim(.Combo1.List(i)) & &quot;'&quot; & &quot;,&quot; _
& res!CHALL & &quot;,&quot; _
& &quot;'&quot; & Trim(res!Dis) & &quot;'&quot; & &quot;,&quot; _
& res!qty & &quot;,&quot; _
& colL1.Item(res!Dis) & &quot;,&quot; _
& ((res!qty) * colL1.Item(res!Dis)) & &quot;,&quot; _
& ttax.ST & &quot;,&quot; _
& ttax.cst & &quot;,&quot; _
& &quot;'&quot; & Trim(ttax.FORM_NUMBER) & &quot;'&quot; & &quot;,&quot; _
& &quot;'&quot; & Trim(ttax.FORM_NAME) & &quot;'&quot; & &quot;,&quot; _
& Val(ttax.OTHER1) & &quot;,&quot; _
& 0 & &quot;,&quot; _
& tless & &quot;,&quot; _
& ttax.SURCHARGE & &quot;,&quot; _
& &quot;'&quot; & Trim(wor) & &quot;'&quot; & &quot;)&quot;
'MsgBox (SQL)
comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute

If (res.EOF = True) Then
Exit Do
End If

res.MoveNext

Loop

'// Setting for the printer

Printer.PrintQuality = vbPRPQMedium

'// PRINTING THE BILL ACCORDING TO THE COMPANY NAMES
If (ttax.CONAME = &quot;Maru Industries&quot;) Then
CR1.ReportFileName = App.Path & &quot;\Bill.rpt&quot;
CR1.DataFiles(0) = &quot;D:\Maru\Maru.mdb&quot;
CR1.Destination = crptToPrinter
CR1.PrintReport

Printer.EndDoc
End If

If (ttax.CONAME = &quot;Maruti Industries&quot;) Then
CR1.ReportFileName = App.Path & &quot;\Maruti.rpt&quot;
CR1.DataFiles(0) = &quot;D:\Maru\Maru.mdb&quot;
CR1.Destination = crptToPrinter
CR1.PrintReport
Printer.EndDoc
'CR1.Action = crRunReport

End If

If (ttax.CONAME = &quot;Suresh Welding Works&quot;) Then
CR1.ReportFileName = App.Path & &quot;\Suresh.rpt&quot;
CR1.DataFiles(0) = &quot;D:\Maru\Maru.mdb&quot;
CR1.Destination = crptToPrinter
CR1.PrintReport
Printer.EndDoc
'CR1.Action = crRunReport

End If

If (ttax.CONAME = &quot;Merit Agriculture Works&quot;) Then
CR1.ReportFileName = App.Path & &quot;\merit.rpt&quot;
CR1.DataFiles(0) = &quot;D:\Maru\Maru.mdb&quot;
CR1.Destination = crptToPrinter
CR1.PrintReport
Printer.EndDoc
'CR1.Action = crRunReport

End If



'// UPDATING THE BILL FILE
Dim printed As Boolean
printed = True

SQL = &quot;INSERT INTO [bill] ([CName],[BillNO],[Bill_date],[s_date],[E_date],[amount],[Printed],[st],[cst],[surcharge],[other1],[other2],[less],[FormName],[FormNum],[BName]) VALUES (&quot; & &quot;'&quot; & Trim(.Combo1.List(i)) & &quot;'&quot; & &quot;,&quot; _
& BB & &quot;,&quot; _
& &quot;#&quot; & CDate(Me.Text3.Text) & &quot;#&quot; & &quot;,&quot; _
& &quot;#&quot; & CDate(frmBill.MD.Text) & &quot;#&quot; & &quot;,&quot; _
& &quot;#&quot; & CDate(frmBill.MD2.Text) & &quot;#&quot; & &quot;,&quot; _
& CDbl(subtot) & &quot;,&quot; _
& printed & &quot;,&quot; _
& ttax.ST & &quot;,&quot; _
& ttax.cst & &quot;,&quot; _
& ttax.SURCHARGE & &quot;,&quot; _
& ttax.OTHER1 & &quot;,&quot; _
& 0 & &quot;,&quot; _
& ttax.LESS & &quot;,&quot; _
& &quot;'&quot; & Trim(frmBill.Text1.Text) & &quot;'&quot; & &quot;,&quot; _
& &quot;'&quot; & Trim(frmBill.Text2.Text) & &quot;'&quot; & &quot;,&quot; & &quot;'&quot; & Trim(ttax.CONAME) & &quot;'&quot; & &quot;)&quot;
' MsgBox (SQL)

comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute


'// SAVING TO THE TAX FILE TO ADD SALES TAX AND CENTRAL TAX

'// FINDING OUT IF THE THE TAX IS ALREADY ENTERED
SQL = &quot;SELECT COUNT(*) AS RR FROM [stax] &quot; _
& &quot;WHERE [billno] = &quot; & BB _
& &quot; AND [bill_date ] = #&quot; & CDate(Me.Text3.Text) & &quot;#&quot; _
& &quot; AND [BName] = '&quot; & Trim(ttax.CONAME) & &quot;'&quot;
comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute
If (tres!rr < 1) Then

'// Adding the Sale tax

SQL = &quot;INSERT INTO [stax] ([billno],[bill_date],[stax],[cst],[BName]) VALUES (&quot; _
& BB & &quot;,&quot; _
& &quot;#&quot; & CDate(Me.Text3.Text) & &quot;#&quot; & &quot;,&quot; _
& CDbl(stax1) & &quot;,&quot; _
& CDbl(cst) & &quot;,&quot; & &quot;'&quot; & Trim(ttax.CONAME) & &quot;'&quot; & &quot;)&quot;
'MsgBox (SQL)
comm.CommandText = SQL
Set tres = New Recordset
Set tres = comm.Execute
Else
MsgBox (&quot;TO EDIT THE BILL PLEASE SWITCH TO MAUNAL MODE&quot;), vbInformation, &quot;Critical Error&quot;
End If

End If
'// THIS SHOWS THE PROGRESS BAR VALUE
Me.Text2.Text = Val(Me.Text2.Text) + 1
pb1.Value = Int((CSng(Val(Text2.Text)) / CSng(Val(Text1.Text))) * 100)
Next i

End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top