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

A2K - help with array search

God knows I've had my run-ins with arrays but this problem is really killing
me!

I'm looping through a recordset. For each record I need to look at a field
value and then see if it exists in a 2D array. It could be any one of the
values in the array and they are not in a particular order.

I don't think there's a built-in way of doing this IIRC but I need a
solution.

Many thanks
Martin
Feb 7 '06 #1
2 1511
How is the 2D array being populated? What is the data source of the 2D
array? Instead of populating a 2D array you should populate another
temp table. Then you can use DLookUp to see if your field exists in the
one table in the other table like this:

tbl1 is your main table, tbl2 is what used to be the 2D array

Dim DB As DAO.Database, RS As DAO.Recordset
Dim str1 As Variant
Set DB = CurrentDB
Set RS = DB.OpenRecordset("tbl1")
Do While Not RS.EOF
str1 = _
& DLookUp("fldz", "tbl2", "fldz = '" & RS!fldx & "'")
If IsNull(str1) Then MsgBox RS!flx & " is not in tbl2"
RS.MoveNext
Loop

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Feb 8 '06 #2
Rich P wrote:
How is the 2D array being populated? What is the data source of the
2D array? Instead of populating a 2D array you should populate
another temp table. Then you can use DLookUp to see if your field
exists in the one table in the other table like this:

tbl1 is your main table, tbl2 is what used to be the 2D array

Dim DB As DAO.Database, RS As DAO.Recordset
Dim str1 As Variant
Set DB = CurrentDB
Set RS = DB.OpenRecordset("tbl1")
Do While Not RS.EOF
str1 = _
& DLookUp("fldz", "tbl2", "fldz = '" & RS!fldx & "'")
If IsNull(str1) Then MsgBox RS!flx & " is not in tbl2"
RS.MoveNext
Loop

Rich

*** Sent via Developersdex http://www.developersdex.com ***


Cheers Rich, I think you're right about that or I could tag the records in
some way. Trying to look up values in an array seems impossible.
Feb 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LRW | last post by:
I have a page that's doing a search of a database, create an array and displays it. And I have it displaying the array just fine, but when I try to sort it, I get the error: Warning: sort()...
7
by: bettina | last post by:
I want to define an array bidimensional as a session array. <? $continents = array (1 => $europe, $america, $oceania, $africa, $asia); $i = 1; do { $search_countries = mysql_query("SELECT...
5
by: Richard Berg | last post by:
Hello, I need to search a byte array for a sequence of bytes. The sequence may include wildcards. For example if the array contains 0xAA, 0xBB, 0xAA, OxDD then I want to be able to search for...
4
by: Angus Comber | last post by:
Hello I have received a lot of help on my little project here. Many thanks. I have a struct with a string and a long member. I have worked out how to qsort the struct on both members. I can...
7
by: simkn | last post by:
Hello, I'm writing a function that updates an array. That is, given an array, change each element. The trick is this: I can't change any elements until I've processed the entire array. For...
0
by: frack78 | last post by:
I have written a binary search algorithm in java. I have a statement that when the search key is found it is printed to a terminal window. This statement when when called just keeps printing over and...
3
by: mdh_2972 | last post by:
I have an array of over 1000 links in a .JS file. I do not want to put the whole thing on my page because it would take to long to render the page. So how can I randomly pick 1 element from the...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
8
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array;...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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...

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.