Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

ADO Search Examples

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
a1785
Asked:
a1785
1 Solution
 
detiegeCommented:
What do you want to pass as parameter ?

The date ?
0
 
detiegeCommented:
You can do that:

Dim Buff As String

Buff = Param  // Buff = your parameter

object.Find("Week_Beginning_DT = '" & Buff & "'")
0
 
detiegeCommented:
OOOOPs // = ' = Comment
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
detiegeCommented:
0
 
ca_hecklerCommented:
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
 
wsh2Commented:
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
 
a1785Author Commented:
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now