i want to display a selected record from my database to the data report in VB6. i used the foll. code, where cuno is the value of a textbox. i m passing the value of cuno through a module.

SELECT * FROM Bill WHERE ID=cuno

but when i run it, it gives me this error:

No value given for one or more required parameters.

plz help me.
n i also wanted to know how to make data report an mdi child.

Recommended Answers

All 16 Replies

you need to pass a value for parameter. how you create your report and what code you write. plz submit.

I think u have to write:
"SELECT * FROM Bill WHERE ID='" & text1.text & "'"

If cuno is of numeric type, then this will be more suitable:

"SELECT * FROM Bill WHERE ID= " & val(text1.text) & " "

If it is of Text type then,

"SELECT * FROM Bill WHERE ID= '" & trim(text1.text) & "' "

Assuming that you are using MS Access database... :)

thanx for your replies. i forgot to mention that i have written that sql sttmt in the properties of the data report. n my text1.text is in a form. thats y i have tried to use the module(cuno as integer) in order to pass the value of text1.text to the report. but '" & cuno & "' dint work. it gives the error : Data type mismatch in criteria expression.

thanx for your replies. i forgot to mention that i have written that sql sttmt in the properties of the data report. n my text1.text is in a form. thats y i have tried to use the module(cuno as integer) in order to pass the value of text1.text to the report.
if i use this:
"SELECT * FROM Bill WHERE ID='" & cuno & "'"
Error:Failed getting Rowset(s) from current data source
n if i use this:
SELECT * FROM Bill WHERE ID='" & cuno & "'
Error: Data type mismatch in criteria expression
n without '" & & "'
i.e. SELECT * FROM Bill WHERE ID= cuno
Error:No value given for one or more required parameters
Plz help

is there a way to solve this? or is there any other way to pass a numeric value from a form to the report, and display that particular record depending on that value?

Try to seperate the ' from your statement -

"SELECT * FROM Bill WHERE ID=" & "'" & cuno.Text & "'"

Hope this solves your problem..

Go to www.planet-source-code.com/vb
Register for free and go to Search type DataReport.

There you have thousands of sample code projects.

Regards, Davor Geci

how do i print only the last record in the data report? ive searched for it on the net. but dint get a suitable answer. plz help
is this correct:
SELECT TOP 1 * FROM Bill ORDER BY ID DESC
?

I wold do it like this:
To get the last ID in table:

Dim lngID as long
Dim mrs As New.ADODB.Recordset
dim sSQL as String

sSQL = "SELECT Last(ID) AS LastID FROM Bill"
mrs.Open sSQL, con, adOpenStatic, adLockOptimistic
lngID =0
if mrs.recordcount > 0 then
    lngID = iif(isnull(mrs!LastID),0,mrs!LastID)
end if

'Then you can put it in your SQL for DataReport

sSQL = "SELECT * FROM Bill WHERE ID = " & lngID

'cleaning
if mrs.state = 1 then mrs.close
set mrs = nothing

Hope this helped
Regards, Davor Geci

dajaci, juniorj has the faster and prefered way in which to pull the singular last record from the database as it only requires the program, the network (if on a network), the database, the hard drive(s), to be called only once while your code calls all the above twice and increases not only wear and tear but time.

Good Luck

last in wt sense, date, position ???. every record in the table has an identification and u can select only this record in the sql statement like select * from table_name where key=....This query selects only one record at a time.

Bashire, look at dajaci's post above mine, which is above yours, and you will see that dajaci's post has two queries that are executed to get the last/newest record entered. The first to get that ID and the second to get the records that belong with that ID...

ALSO: YOU ARE GUILTY OF NECROPOSTING! Please do not revive old threads. It just creeps people out! :)

THAT OLD SONG??? Hello love. goodbye happiness, I think I'm ggoonna dyyye. Please leave the burried to themselves.....

Bashire, look at dajaci's post above mine, which is above yours, and you will see that dajaci's post has two queries that are executed to get the last/newest record entered. The first to get that ID and the second to get the records that belong with that ID...

ALSO: YOU ARE GUILTY OF NECROPOSTING! Please do not revive old threads. It just creeps people out! :)

thx for the reply. I think i have not been able to communicate to your goodself wt I actually want. in your mentioned solution, there is only one table and only one record is extracted and displayed on report. I have two tables table1, table2 not related in any manner. The reports on these two tables can be prepared separately but i want both these tables to be shown on the same report one after the other.
morover, regarding NECROPOSTING, an option was provided to revive the said thread. Still I m sorry.

thx

NOW YOUR HIGHJACKING!!!! Please start your own thread for your questions...

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.