Solved

ADO  Search Examples

Posted on 2000-04-19
7
287 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 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