954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

display a record in data report in vb6

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.

juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

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

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

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

AnisMetal
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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

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

If it is ofText type then,

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


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

akhileshbc
Newbie Poster
14 posts since Nov 2009
Reputation Points: 10
Solved Threads: 5
 

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.

juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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

juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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?

juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

Try to seperate the ' from your statement -

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


Hope this solves your problem..

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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

dageci
Newbie Poster
3 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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
?

juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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

dageci
Newbie Poster
3 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

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.

Bashir ahmad
Light Poster
30 posts since May 2010
Reputation Points: 10
Solved Threads: 1
 

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

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

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

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

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

Bashir ahmad
Light Poster
30 posts since May 2010
Reputation Points: 10
Solved Threads: 1
 

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

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: