473,404 Members | 2,170 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,404 software developers and data experts.

Using .Find with multiple search criteria

38
I have this code:

strAny = "[YearId] = " & rsTemp!YearId
rsPerm.Find strAny

and it works. However, when I do the following it doesn't

strAny = "[YearId] = " & rsTemp!YearId & " AND " & _
"[DeptId] = " & rsTemp!DeptId & " AND " & _
"[CatId] = '" & rsTemp!CatId & "'"
rsPerm.Find strSQL

Can anyone tell me what I'm doing wrong? I should add YearId and DeptId are numeric and CatId is String.

Greatly appreciated.
Salzan
Feb 23 '08 #1
8 5976
puppydogbuddy
1,923 Expert 1GB
I have this code:

strAny = "[YearId] = " & rsTemp!YearId
rsPerm.Find strAny

and it works. However, when I do the following it doesn't

strAny = "[YearId] = " & rsTemp!YearId & " AND " & _
"[DeptId] = " & rsTemp!DeptId & " AND " & _
"[CatId] = '" & rsTemp!CatId & "'"
rsPerm.Find strSQL

Can anyone tell me what I'm doing wrong? I should add YearId and DeptId are numeric and CatId is String.

Greatly appreciated.
Salzan
Salzan,
Try changing this: rsPerm.Find strSQL

To this: rsPerm.Find strAny
Feb 23 '08 #2
salzan
38
Sorry that was a typo - it's strAny. The variable name is not it.
Feb 23 '08 #3
FishVal
2,653 Expert 2GB
Hi, Salzan.

Do you mean ADODB.Recordset?
If so then this may give an answer to your question.

Regards.
Fish
Feb 23 '08 #4
puppydogbuddy
1,923 Expert 1GB
Hi Fish,

And this link compares the Find methods of DAO with ADO.........

http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx
Feb 23 '08 #5
salzan
38
I should have specify that I'm using ADO Recordset. The articles didn't help. My problem is with the criteria string. When I specify only one criteria it works but when I specify multiple criteria with AND operator it give me an error message "arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". I've checked the types of the arguments and they're correct. I don't know what else to search.

Thanks you for your help.
Salzan
Feb 23 '08 #6
puppydogbuddy
1,923 Expert 1GB
I should have specify that I'm using ADO Recordset. The articles didn't help. My problem is with the criteria string. When I specify only one criteria it works but when I specify multiple criteria with AND operator it give me an error message "arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". I've checked the types of the arguments and they're correct. I don't know what else to search.

Thanks you for your help.
Salzan
Try it this way and see if it helps:

strAny = "[YearId] = " & rsTemp!YearId & _
" AND [DeptId] = " & rsTemp!DeptId & _
" AND [CatId] = '" & rsTemp!CatId & "'"
Feb 23 '08 #7
Scott Price
1,384 Expert 1GB
According to the Access help file, the .Find method of the ADO recordset only supports one column searches. In other words, you are out of luck trying to set multiple column criteria!

In the VBA code editor window, position your cursor in the word Find and press F1, this brings up the help file with this specific information.

Regards,
Scott
Feb 23 '08 #8
salzan
38
THANK YOU ALL. Atleast I know I'm not doing it wrong. I think I'll create a compound column, concatenate the values together, and search against it. It should accomplish what I'm after.
Feb 23 '08 #9

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

Similar topics

3
by: Pete | last post by:
I'm currently doing a database that uses comboboxes to look up records in other tables, whether they be lookup tables or otherwise. When a user needs to add an item to one of these tables, the...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
0
by: Sam | last post by:
I am fairly new to ASP. Net 2.0, background MS Access 2000/2003 and working knowledge of SQL 2000. Scenario: Page1: Blank Page loads with 2 Text Boxes (TxtLast, TxtFirst), a Command...
1
by: Casey | last post by:
Hi, How would one allow for possible multiple search criteria using FREETEXTTABLE. For example, my table "listings" has a full-text search catalog, and I may want to: SELECT * FROM listings...
6
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result...
3
by: AishaKhalfan | last post by:
Hi, :wave: I have many search criteria in my program, such as: search by name, search by age, search by gender, search by city the user can search by name only, or by name and age, or by...
1
by: Froefel | last post by:
I'm trying to populate a gridview control based on a user's search criteria, but what seemed like a trivial task turns out to be a nighmare for this newbie... maybe someone can help. Here's the...
0
by: redpears007 | last post by:
Morning all! :) I have a database with multiple linked tables. I have created a search form with one txt box, for entering search criteria, and a listbox for each of the tables to isplay the...
3
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
1
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
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...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.