Hello can you help me please i got problem in making the crystal report 9,i have form which is inquiry of customer no. if i will input 0001 keydown this will display the data and i want to print it to have hard copy...can you help me please how to make it...thank you in advance hoping for your positive response....

Recommended Answers

All 12 Replies

Jemz, you from all people should know that we can not help you with what you gave us.

Give us more information please.:)

Jemz, you from all people should know that we can not help you with what you gave us.

Give us more information please.:)

hello sir thank you for the reply, sir i want to print my data the problem is that i don't know how to use the cr9 if i will input the customer no...

example:

0001 ===>keydown

this will display on  my flexgrid

customerNO    Name            product          units            price         date

0001         jemz gimz        Monitor          pcs              7,000.00      12-5-10

then i have my cmdprint if i will click this it will print...can you help me on this sir please...thank you in advance hoping for your positive responds...

In your recordset statement -

rs.Open "SELECT * FROM MyTable WHERE customerNO = " & "'" & txtCustNo & "'", cn..........

If rs.BOF = True Or rs.EOF = True Then
MsgBox "Customer does not exist. No data found"
Exit Sub
Else
Set MyCReport.Datasource = rs
'Add the code here from the link I gave you last time with your previous post. It gave you all the information you needed to populate the report AND print it.
End If

If you just want to print the data in the flexgrid -

Private Sub Print_Click()


Dim i As Integer
Dim J As Integer
Dim x As Integer
Dim Y As Integer
Dim test As Variant
x = 1500
Y = 4500


Printer.CurrentX = 3500
Printer.CurrentY = 3000
Printer.FontName = "Arial"
Printer.FontSize = 16
Printer.Print "GRADE SHEET"


setXY 1500, 4000, 14, True

For i = 0 To MSHFlexGrid1.Rows - 1
'This checks to see if a page break is needed

If Printer.CurrentY + Printer.TextHeight(MSHFlexGrid1.Text) > Printer.ScaleHeight - 600 Then
Printer.NewPage
End If

MSHFlexGrid1.Row = i 'Set the active row

For J = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.Col = J 'Set the current column

'Send the field to the print line and add the tab.
'Notice the semicolon at the end of the line.
If i = 0 Then
setXY x, Y, 12, True
Else
setXY x, Y, 10, False
End If

Printer.Print Trim$(MSHFlexGrid1.Text)

If J = 1 Then
x = x + 3500
Else
x = x + 2000
End If


Next
Y = Y + 300
x = 1500
Next


Printer.EndDoc
MsgBox ("Document sent to the printer.")
End Sub

In your recordset statement -

rs.Open "SELECT * FROM MyTable WHERE customerNO = " & "'" & txtCustNo & "'", cn..........

If rs.BOF = True Or rs.EOF = True Then
MsgBox "Customer does not exist. No data found"
Exit Sub
Else
Set MyCReport.Datasource = rs
'Add the code here from the link I gave you last time with your previous post. It gave you all the information you needed to populate the report AND print it.
End If

If you just want to print the data in the flexgrid -

Private Sub Print_Click()


Dim i As Integer
Dim J As Integer
Dim x As Integer
Dim Y As Integer
Dim test As Variant
x = 1500
Y = 4500


Printer.CurrentX = 3500
Printer.CurrentY = 3000
Printer.FontName = "Arial"
Printer.FontSize = 16
Printer.Print "GRADE SHEET"


setXY 1500, 4000, 14, True

For i = 0 To MSHFlexGrid1.Rows - 1
'This checks to see if a page break is needed

If Printer.CurrentY + Printer.TextHeight(MSHFlexGrid1.Text) > Printer.ScaleHeight - 600 Then
Printer.NewPage
End If

MSHFlexGrid1.Row = i 'Set the active row

For J = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.Col = J 'Set the current column

'Send the field to the print line and add the tab.
'Notice the semicolon at the end of the line.
If i = 0 Then
setXY x, Y, 12, True
Else
setXY x, Y, 10, False
End If

Printer.Print Trim$(MSHFlexGrid1.Text)

If J = 1 Then
x = x + 3500
Else
x = x + 2000
End If


Next
Y = Y + 300
x = 1500
Next


Printer.EndDoc
MsgBox ("Document sent to the printer.")
End Sub

Hello sir thank you for your help sir, i will try for this sir and i will write again if i have doubt...by the way sir I have just now know that it is possible to print directly the data in my flexgrid thank you also for this sir and i will also try for this...more power to you...

As always, its a pleasure jemz.:)

Please mark this as solved, thanks.

In your recordset statement -

rs.Open "SELECT * FROM MyTable WHERE customerNO = " & "'" & txtCustNo & "'", cn..........

If rs.BOF = True Or rs.EOF = True Then
MsgBox "Customer does not exist. No data found"
Exit Sub
Else
Set MyCReport.Datasource = rs
'Add the code here from the link I gave you last time with your previous post. It gave you all the information you needed to populate the report AND print it.
End If

If you just want to print the data in the flexgrid -

Private Sub Print_Click()


Dim i As Integer
Dim J As Integer
Dim x As Integer
Dim Y As Integer
Dim test As Variant
x = 1500
Y = 4500


Printer.CurrentX = 3500
Printer.CurrentY = 3000
Printer.FontName = "Arial"
Printer.FontSize = 16
Printer.Print "GRADE SHEET"


setXY 1500, 4000, 14, True

For i = 0 To MSHFlexGrid1.Rows - 1
'This checks to see if a page break is needed

If Printer.CurrentY + Printer.TextHeight(MSHFlexGrid1.Text) > Printer.ScaleHeight - 600 Then
Printer.NewPage
End If

MSHFlexGrid1.Row = i 'Set the active row

For J = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.Col = J 'Set the current column

'Send the field to the print line and add the tab.
'Notice the semicolon at the end of the line.
If i = 0 Then
setXY x, Y, 12, True
Else
setXY x, Y, 10, False
End If

Printer.Print Trim$(MSHFlexGrid1.Text)

If J = 1 Then
x = x + 3500
Else
x = x + 2000
End If


Next
Y = Y + 300
x = 1500
Next


Printer.EndDoc
MsgBox ("Document sent to the printer.")
End Sub

Hello sir can you please help me i am confuse of the code i put it to my txtcno_KeyDown
i got an error...please correct my code sir also sir my crviewer do i still need to put code on it?please help me sir for this problem... thank you in advance hoping for your positive response...more power to you...

What kind of error did you get?

What kind of error did you get?

hello sir thank you for the reply..my error is user type not define...

sir i am opening 4 tables here..

Public con As ADODB.Connection
    Public cmd As ADODB.Command
    Public mch_rs As ADODB.Recordset
    Public order_rs As ADODB.Recordset
    Public cust_rs As ADODB.Recordset
    Public od_rs As ADODB.Recordset
    Public sql As String
    Public m_cno As String
    Public m_orno As String, m_amt As String
    Public amount As Double, sum As Double
    Dim crystal As CRAXDRT.Application
    Dim report As CRAXDRT.report
    Private Sub Form_Load()
    Set con = New ADODB.Connection
    Set cmd = New ADODB.Command
    Set mch_rs = New ADODB.Recordset
    Set cust_rs = New ADODB.Recordset
    Set order_rs = New ADODB.Recordset
    Set od_rs = New ADODB.Recordset
    
    With con
       .ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\project.mdb"
       .Open
    End With
    header
    End Sub
    Public Sub header()
    
     grd.clear
     grd.Rows = 2
     grd.Cols = 7
     grd.ColWidth(2) = 3000
      grd.ColWidth(3) = 1500
     grd.ColWidth(5) = 1500
     grd.ColWidth(6) = 1500
     
     With grd
      .TextMatrix(0, 0) = "seqno"
      .TextMatrix(0, 1) = "mchno"
      .TextMatrix(0, 2) = "merchandise name"
      .TextMatrix(0, 3) = "umsr"
      .TextMatrix(0, 4) = "qty"
      .TextMatrix(0, 5) = "uprice"
      .TextMatrix(0, 6) = "amount"
     
    End With
    End Sub
    Private Sub txtcno_KeyDown(KeyCode As Integer, Shift As Integer)
    
     If order_rs.State = adStateOpen Then
       order_rs.Close
       End If
    
         m_cno = Trim(txtcno.Text)
         If KeyCode = 13 Then
              sql = "select * from customer_table where cust_no = '" & m_cno & "'"
               Set cust_rs = con.Execute(sql)
            
                 If cust_rs.BOF = True And cust_rs.EOF = True Then
                   MsgBox "Sorry" + "  " + m_cno + "  " + "not found in the customer table", vbCritical
                   Exit Sub
                   Else
                        lblname.Caption = cust_rs!cust_name
                        lbladdress.Caption = cust_rs!cust_address
                        lbltelno.Caption = cust_rs!cust_telno
                        
                        sql = "select * from order_table where order_custno = '" & m_cno & "'order by order_slipno asc,order_date asc"
                        order_rs.Open sql, con, adOpenStatic
                        
                        txtcno.Locked = True
                        
                        Set crystal = New CRAXDRT.Application
                        
                        Set report = crystal.OpenReport(App.Path & "\report1.rpt")
                           
                        
                        report.DiscardSavedData
                        report.Database.SetDataSource rs
                        CRViewer.ReportSource = report
                        CRViewer.ViewReport
                        Do While CRViewer.IsBusy
                        DoEvents
                        Loop                                                            
                        
                        CRViewer.Zoom 94
          
                       End If
                    cust_rs.Close
                    
               End If
    
    End Sub

please help me sir thank you in advance hoping for your positive response...

This is your problem here -

If order_rs.State = adStateOpen Then
order_rs.Close
End If

You have a reference to a recordset that has not been declared. Do the same with the others in the sub as you did in your form load event...:)

Set order_rs = new adodb.recordset

This is your problem here -

You have a reference to a recordset that has not been declared. Do the same with the others in the sub as you did in your form load event...:)

Set order_rs = new adodb.recordset

hello sir thank you for your reply where am i going to put my

Set order_rs = new adodb.recordset

in line 71?please help me sir thank you in advance hoping for your positive response...

You will add it BEFORE the order_rs.Open statement.:)

Jemz, please mark this as solved, referring our email conversation. I don't think we will add anything more on here anymore, thanks.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.