HOW TO WRITE SQL USING CRYSTAL REPORTS 9 IN VB6?

Dear Friends,

I designed one INVOICE crystal reports9 using vb6 and connected with access database. It was displaying all the records. Now i want to display particular invoice number. I used below code. but its not executing. default code only executing. Can u plz help me....

Thanks,

Table Name: bill_client
Field Name : bill_INV_No

Private Sub Report_Initialize()
CrystalReport1.SQLQueryString = "Select * from bill_client where bill_INV_No = '5002'"
End Sub

you need to pass the parameter for bill_INV_No dynamically using some control.

try this

Private Sub Report_Initialize()
CrystalReport1.SQLQueryString = "Select * from bill_client where bill_INV_No = & val(text_INV_No.text)"
End Sub

Dear Friend's,

Thankq for your replay

I tried so many ways, but it is not working. Actually I created one report format and linked with parent to child table. Now It was showing all the records properly. But when i am trying to show the one particular record using query, then i am getting this below error message.

Error Message:
"This group section cannot be printed because its condition field is nonexistent or invalid. Format the section to chose another condition field."


This is the default Query from crystal reports:
SHAPE {SELECT * FROM `BILL_Client`} AS BILL_Client APPEND ({SELECT * FROM `BILL_Particulars`} AS BILL_Parti RELATE 'bill_Relation' TO 'bill_Relation') AS BILL_Parti

Now I tried like this.
SELECT * FROM BILL_Client INNER JOIN BILL_Particulars ON BILL_Client.bill_Relation = BILL_Particulars.bill_Relation WHERE (BILL_Client.bill_INV_No='5002')

OR
SHAPE {SELECT * FROM BILL_Client INNER JOIN BILL_Particulars ON BILL_Client.bill_Relation = BILL_Particulars.bill_Relation WHERE (BILL_Client.bill_INV_No='5002')} AS SQLcommand


And I tried with DataEnvironment also like
Private Sub Report_Initialize()
Database.SetDataSource DEnv.Commands("bill_client").Execute
End Sub

Private Sub DataEnvironment_Initialize()
Commands("bill_client").CommandText = "SHAPE {SELECT * FROM BILL_Client INNER JOIN BILL_Particulars ON BILL_Client.bill_Relation = BILL_Particulars.bill_Relation WHERE (BILL_Client.bill_INV_No='5002')} AS SQLCommand"
End Sub

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.