473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Filling in Data Table Using Loop: Check to see if Data Changes

I'm filling in a Report with SQL data using VB code. I'm using LOOP and MoveNext. Before using MoveNext, I would like to be able to check whether the new data is equal to the previous data that was added. I'm not sure if MovePrevious is the best way to accomplish this. Here's an example of my code:

With rs
.MoveFirst
strData = Trim(!data)

Do While Not .EOF

If Not .BOF Then
.MovePrevious
strDataPrev = Trim(!data)
.MoveNext
End If

If (strData <> strDataPrev) Then

'The record is new

End If

.MoveNext
Loop
.Close
End With

Will this work? Or is another method better?
Aug 31 '07 #1
3 2606
Tig201
103 100+
[quote=nico3334]I'm filling in a Report with SQL data using VB code. I'm using LOOP and MoveNext......QUOTE]

The first thing I would Note is that you are not setting “strData” After the first Record. Next I would recommend setting “strDataPrev = strData” after you check to see if they are equal as apposed to moving backwards and forwards through the table.
Aug 31 '07 #2
QVeen72
1,445 Expert 1GB
Hi,

Open a New Recordset for the condtion and check with the data.. Why open whole recset and loop thru and do the "Moves"..?

Regards
Veena
Sep 2 '07 #3
Hi,

Open a New Recordset for the condtion and check with the data.. Why open whole recset and loop thru and do the "Moves"..?

Regards
Veena
Sorry, I added in some extra code to try to describe my problem better.

I'm retrieving data from a sql table using .movenext and loop. When it is inserting the data, I would like it to check whether the next record it will be adding is equal to the last record it added. If it not is equal, I want to add an occurence to an array. Does this code look ok? Thanks.
''''''''''''''''''''''
Dim arrData() As String
ReDim arrData(Col, 0)

With rs
.MoveFirst
strData = Trim(!Data)

Do While Not .EOF

If Not .BOF Then
.MovePrevious
strDataPrev = Trim(!Data)
.MoveNext
End If

If (strData <> strDataPrev) Then

'Add Occurence to Array
ReDim Preserve arrData(UBound(Col) + 1)

End If

arrData(Col, 0) = strData

.MoveNext
Loop
.Close
End With
Sep 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raptor | last post by:
I'm using a single script to generate a table with <input>s in each row. I fill the array with initial values, then write it out to the table and let the user edit the values. Something like: ...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
3
by: crjunk | last post by:
I have a 3 table in my DataSet that I'm filling with data. After I've filled these 3 tables, I'm then trying to run a query that will fill a 4th table in the DataSet with data from the three...
11
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
3
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
4
by: sklett | last post by:
(I posted this in a databinding NG, but it's a VERY low traffic NG so I thought I would post here as well. I hope no one minds too much, if you do I'm sorry) I have a DGV that is bound to a...
6
by: lukasso | last post by:
Hi, this is my code that should produce something like a timetable for a few days with each day divided into 30 minute pieces. It makes query from MySQL and then creates a 2d $array which then is to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.