Solved

ADO  Search Examples

Posted on 2000-04-19
7
279 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
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now