Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

VB6 Navigating Recordsets

 
   Database Help (Home) -> Visual Basic RSS
Related Topics:
sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table and there a column wich is data type All data in this column is in form So why when i run .asp page with simple query to..

arrays - is there a way to the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a for example after 5 records printed. Thank you all

Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to I have a table that contains for work Contained in the table are these are groupings of machining

Scroll Bars - Is there a way to find the size of on a system using Visual Basic 6.0? I know how to look and change them on the display but I don't know how to access that from within Visual Basic.
Next:  Visual Basic: Shared Database Connection?  
Author Message
Kevin Robinson

External


Since: Oct 12, 2004
Posts: 5



(Msg. 1) Posted: Thu Feb 17, 2005 2:40 pm
Post subject: VB6 Navigating Recordsets
Archived from groups: comp>lang>basic>visual>database (more info?)

I hope that someone can help with a this problem:

I have a table containing 5 different records and I want to print out only
those records which met a given condition.

My code is similar to this where mydata1,2 and 3 represent data held in 3
different rows in the 5 row table.:

With rsTemp
.movefirst
Do While Not .EOF
if condition1 = true then
print #1 mydata1
else if condition2 = true then
print #1 mydata2
else if condition3 = true then
print #1 mydata3
end if
.movenext
loop
end with

The problem is that some of the same rows print out more than once so I end
up with 15 rows and not the three
distinct rows expected from he code..
How can I control this using if then statements within a loop? Or is there
an alternative approach to this
problem?

Regards

Kevin

 >> Stay informed about: VB6 Navigating Recordsets 
Back to top
Login to vote
Rob's News

External


Since: Feb 17, 2005
Posts: 1



(Msg. 2) Posted: Thu Feb 17, 2005 6:40 pm
Post subject: Re: VB6 Navigating Recordsets [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Kevin Robinson" <k.s.robinson.DeleteThis@btinternet.com> wrote in
news:cv2p4l$2nf$1@titan.btinternet.com:

 > I hope that someone can help with a this problem:
 >
 > I have a table containing 5 different records and I want to print out
 > only those records which met a given condition.
 >
 > My code is similar to this where mydata1,2 and 3 represent data held
 > in 3 different rows in the 5 row table.:
 >
 > With rsTemp
 > .movefirst
 > Do While Not .EOF
 > if condition1 = true then
 > print #1 mydata1
 > else if condition2 = true then
 > print #1 mydata2
 > else if condition3 = true then
 > print #1 mydata3
 > end if
 > .movenext
 > loop
 > end with
 >
 > The problem is that some of the same rows print out more than once so
 > I end up with 15 rows and not the three
 > distinct rows expected from he code..
 > How can I control this using if then statements within a loop? Or is
 > there an alternative approach to this
 > problem?
 >
 > Regards
 >
 > Kevin
 >
 >
 >

Hi Kevin. You don't say what condition1, condition2, and condition3 are.
Are they boolean variables? If so, I assume that their values are set at
some point in your code before your loop begins? If so, then then their
value does not depend on anything in your recordset, so for each
condition that is true, all five records will be printed. In fact, since
you say 15 rows are printed, it's pretty clear that all three conditions
are true.

If on the other hand condition1, condition2, and condition3 are functions
or expressions, evaluated afresh at each point in your loop, then if you
are expecting three records but are getting 15, there is something wrong
with the way that your code is evaluating them.

I think you need to explain a bit more about these conditions in order
for anyone to pinpoint what is wrong.

Regards

Rob<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: VB6 Navigating Recordsets 
Back to top
Login to vote
Kevin Robinson

External


Since: Oct 12, 2004
Posts: 5



(Msg. 3) Posted: Mon Feb 21, 2005 2:40 pm
Post subject: Resolved [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This has been resolved.
"Kevin Robinson" <k.s.robinson.DeleteThis@btinternet.com> wrote in message
news:cv2p4l$2nf$1@titan.btinternet.com...
 > I hope that someone can help with a this problem:
 >
 > I have a table containing 5 different records and I want to print out only
 > those records which met a given condition.
 >
 > My code is similar to this where mydata1,2 and 3 represent data held in 3
 > different rows in the 5 row table.:
 >
 > With rsTemp
 > .movefirst
 > Do While Not .EOF
 > if condition1 = true then
 > print #1 mydata1
 > else if condition2 = true then
 > print #1 mydata2
 > else if condition3 = true then
 > print #1 mydata3
 > end if
 > .movenext
 > loop
 > end with
 >
 > The problem is that some of the same rows print out more than once so I
end
 > up with 15 rows and not the three
 > distinct rows expected from he code..
 > How can I control this using if then statements within a loop? Or is there
 > an alternative approach to this
 > problem?
 >
 > Regards
 >
 > Kevin
 >
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: VB6 Navigating Recordsets 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]