Solved

ADO  Search Examples

Posted on 2000-04-19
7
292 Views
Last Modified: 2010-08-05
I want to search a recordset from a SQL database for a value that I want to pass as a parameter.  The object.find("Week_Beginning_DT = '04/20/2000') is fine but It does not let me pass a value as a parameter.  It wants a string expression.  What am I doing wrong or is there a better way of doing it.

Thanks,
A1785
0
Comment
Question by:a1785
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:detiege
ID: 2730737
What do you want to pass as parameter ?

The date ?
0
 
LVL 1

Expert Comment

by:detiege
ID: 2730797
You can do that:

Dim Buff As String

Buff = Param  // Buff = your parameter

object.Find("Week_Beginning_DT = '" & Buff & "'")
0
 
LVL 1

Expert Comment

by:detiege
ID: 2730808
OOOOPs // = ' = Comment
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:detiege
ID: 2730901
0
 
LVL 1

Expert Comment

by:ca_heckler
ID: 2731981
Or you can use T-SQL and build your search as a query:

tTarget = "this is what you looking for"
tQuery = "Select * from MyTable where " _
         "MyField ='" & tTarget & "';"

objRecordset.Open tQuery, objConnection

if (objRecordset.EOF) then
   MsgBox "Not found !"
else

   do while (not objRecordset.EOF)
      'do something here ...
   loop

end if
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 150 total points
ID: 2732320
You have to put # before and after your date so that SQL knows that is what you are passing.

object.find("Week_Beginning_DT = #04/20/2000#)

To do this dynamically try:

Dim strFind as String

strFind = "Week_Beginning_DT = " _
   & "#" & Format(MyDate, "mm/dd/yyyy") & "#"
object.Find (strFind)
0
 

Author Comment

by:a1785
ID: 2749488
Thanks
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month9 days, left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question