1,105,281 Community Members

display a record in data report in vb6

Member Avatar
juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
abu taher
Practically a Posting Shark
859 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 78 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
AnisMetal
Newbie Poster
1 post since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
akhileshbc
Newbie Poster
14 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
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... :)

Member Avatar
juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Try to seperate the ' from your statement -

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

Hope this solves your problem..

Member Avatar
dageci
Newbie Poster
3 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
juniorj
Newbie Poster
5 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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
?

Member Avatar
dageci
Newbie Poster
3 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
vb5prgrmr
Posting Virtuoso
1,670 posts since Mar 2009
Reputation Points: 143 [?]
Q&As Helped to Solve: 299 [?]
Skill Endorsements: 3 [?]
 
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

Member Avatar
Bashir ahmad
Light Poster
30 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
vb5prgrmr
Posting Virtuoso
1,670 posts since Mar 2009
Reputation Points: 143 [?]
Q&As Helped to Solve: 299 [?]
Skill Endorsements: 3 [?]
 
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! :)

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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

Member Avatar
Bashir ahmad
Light Poster
30 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
vb5prgrmr
Posting Virtuoso
1,670 posts since Mar 2009
Reputation Points: 143 [?]
Q&As Helped to Solve: 299 [?]
Skill Endorsements: 3 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: