473,385 Members | 1,357 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,385 software developers and data experts.

Function to compare 2 multirow DAO recordsets

Looking for some help from you experts to compare 2 multirow DAO recordsets. I have code that loads the recordsets correctly. Just trying to compare them and am having problems getting started. For some details:

My data source is a Windows permission scan. It has a path and 3 other fields related to permissions granted on that path including accountname and permission. The fields take the form

strPath bInherited(0/-1) strAccountname strPermission

There can be several rows describing the permissions granted per path. A recordset contains however many permissions there are for a given path. Usually 4-8 per path/recordset.

rs1 contains a path (select distinct) and is used as a guide to all paths for a given database.
rs2 contains the same path as rs1 (child path) and 3 other fields as described above.
rs3 contains the parent path of rs2 (parent path) and 3 other fields as described above.

Looking to compare rs2 and rs3 to see if they match exactly (all 4 fields). If yes go to next path on rs1. If not, then kick out a list into a new table in the same DB.

Would anyone be willing to assist me? I've done VB6 coding but no VBA and seriously nothing like this using DAO and recordsets.
Mar 9 '15 #1
3 1544
twinnyfo
3,653 Expert Mod 2GB
pmagee1024,

The concept is really simple, and I think you have already done the majority of the work yourself.

Using rst2 and rst3, just compare the values of the corresponding fields:

Expand|Select|Wrap|Line Numbers
  1. If rst2.Fields(0) = rst3.Fields(0) then ... etc.
Since you know how many fields are contained in each recordset, you could even use a variable with a For...Next loop:

Expand|Select|Wrap|Line Numbers
  1. For intX = 0 to 3 'Fields are numbered from 0 to (n-1)
  2.     If rst2.Fields(intX) = rst3.Fields(intX) then ... etc.
  3. Next intX
There are many ways to slice and dice this problem, and this is just one simple option. Having a Boolean variable indicating whether there is a discrepancy would be helpful, also.

Hope this gets you on the right track.
Mar 9 '15 #2
jforbes
1,107 Expert 1GB
Yes, you can use the RecordSet structure you have defined and approach it the way Twinnyfo describes. It's probably the most straight forward way with what you have already, but I would like to offer a couple of options.

The first option would be instead of using two RecordSets, rs2 and rs3, I would only use one and order it by the Path column. Then as you are walking through the RecordSet, right before .MoveNext save the column values off to Variables. Then when you are on the next record, you can compare the current RecordSet's values against the values set in the Variables from the previous record and look for discrepancies.

The Second Option, and the one I would recommend, is to create a Query to give you the Exceptions. If you have a Table with all of these values in it, you could create a query that links the table to itself on the Parent/Child relationship and have a Where Clause for records with different permissions. Then you can create a report based on the Query or open it as a RecordSet in code and do whatever action you need to accomplish.
Mar 9 '15 #3
Thanks twinnyfo, that actually worked better than I expected. I have it running as I needed it to. My sincere thanks!
Mar 13 '15 #4

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

Similar topics

7
by: Grahammer | last post by:
Is it possible to compare two objects of the same class directly to each other? In the code below I'm comparing "Search" against "oneForm.thisForm"... Both of these objects are of the class...
4
by: titancipher | last post by:
I have a container that I wish to allow the user to specify a custom comparison method very similar to std::less. However, I want it to function more like memcmp (returning -1 0 1), and I want to...
2
by: Locia | last post by:
How can I compare "if argument"? example: if (leftExpression==RightExpression) After parsing I know the type of RightExpression. I suppone that if RightExpression is wrap into " " is a...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
1
by: Piet | last post by:
How can I stop a function in PHP? When comparing data I want to stop the function on a hit. Function compare($data) { For ($n=1; $n<=10000; $n++) {
3
by: whisher | last post by:
Hi. I've got this simple snippets. /*function isTheSame(string1,string2) { return (string1.toString() == string2.toString()) }*/ function isTheSame(string1,string2) { string1 = new...
3
by: artev | last post by:
in the default sort which is the compare function used? alphabetical ordination is so:arry.sort(); but which is the default function used? is there a good link wich example for alphabetical...
2
by: Peter Proost | last post by:
Hi group, I want to compare path strings in order to sort them, assuming I have got: "a.txt" "dir1\c.txt" "e.txt" "dir1\d.txt" When I compare them using "e.text" would be greater than...
18
by: WaterWalk | last post by:
Hello. Suppose there is an implementation of C++, in which when a class object is allocated, its member functions are also allocated in addition to its data members. So that every class object has...
47
atksamy
by: atksamy | last post by:
Hi, I am trying to compare two recordsets. the first rs1 has random records. The second rs2 has the standard values for those records. Initially I am looking to take each of the records and see if...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.