Not completely random selection

tho28199

Registered User.
Local time
Today, 16:59
Joined
Jan 25, 2007
Messages
28
Hi all,
I am really not understanding this VBA stuff very well, and I can't seem to find the answers I'm looking for so far, so thought I would post this plea for help.
Basically I have 3 tables. Let's call them Original, Temp, and Result. There is a field in each table called Entry, and there can be duplicates of Entry in both Original and Temp.
I begin by selecting a subset of Original, writing those into the Temp and adding a random number at the same time. I then sort Temp by the random number. This is where I am stumped.
I now want to select a subset of Temp and write those into Result, but I do not want any duplicates of Entry in the Result table.
I suspect that I need to have some kind of loop to write the records into the Result table, and within that loop, have a dlookup or similar function checking for duplicates before either passing or appending the record, but I have no idea how to write that code.
Any assistance would be most appreciated.
Thank you,
Stu
 
Could you just put a unique index on the Result table. Then you could append the records and duplicates would not be allowed.
 
Thanks, DJKarl, that is helpful, and I have made some progress. Now, how do I append one record at a time, checking a counter in between, until I have appended the desired number of records?
 
Ahh well that's different than your original post. The original scenario indicated that you wanted all of the records in your subset just not any duplicates. If you only want to add some of the records from that subset I'd look at using recordset objects and the addnew method.
 

Users who are viewing this thread

Back
Top Bottom