Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In this project I am using datareport and dataenvironment for printing the receipt.

Please check the below code

VB
Private Sub cmdprint_Click()
    'Set rpt = New ADODB.Recordset
    'rpt.Open "select * from reception_detail where ID=" & Val(txtid.Text), Con, adOpenStatic, adLockOptimistic, adCmdText

    DataEnvironment1.Commands(1).CommandText = "select ID,patient_name,patient_age,referedby,test,amount from reception_detail where ID=" & Val(txtid.Text)
    rptreciept.PrintReport
    rptreciept.Show
End Sub



When I click on the print command it shows the following the error given below

Run-time error '5':<br />
<br />
Invalid procedure call or argument


and it highlights the following line when I click on debug

DataEnvironment1.Commands(1).CommandText = "select ID,patient_name,patient_age,referedby,test,amount from reception_detail where ID=" & Val(txtid.Text)
Posted
Updated 8-Sep-11 21:16pm
v2
Comments
Dalek Dave 9-Sep-11 3:16am    
Edited for Grammar and Syntax.

Your main problem is VB6.
Don't!

Get VB.Net, apart from it being supported, unlike VB6, there is a lot more functionality.


As for your code, have all the declarations been made prior to this section?
Is Commands an Array?
 
Share this answer
 
Difficult to tell from that, but try checking it in stages. Put a breakpoint in, and look at

DataEnvironment1 - is it valid?
DataEnvironment1.Commands - ok?
DataEnvironment1.Commands(1) - This is probably the problem.
DataEnvironment1.Commands(1).CommandText - should be ok.

If all of that looks good, check the value in txtid and then txtid.Text.
 
Share this answer
 
v2
Comments
Mudasar Ahmad 9-Sep-11 6:44am    
I solve the previous problem but a new error occurs which is:

Failed getting Rowset(s) from current data source

highlights the follwoing line;

rptreciept.PrintReport True

please solve them

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900