0

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.

8
Contributors
16
Replies
29
Views
8 Years
Discussion Span
Last Post by vb5prgrmr
0

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

0

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... :)

0

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.

0

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

Edited by juniorj: n/a

0

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?

0

Try to seperate the ' from your statement -

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

Hope this solves your problem..

0

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
?

0

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

0

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

0

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.

0

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! :)

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.