Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default XL2K: ADO's Find method (once again.)

Maybe no one understood what I was asking before, so let me try this again:

In this example:

recordset.Find "FIELD = 'MyVar'"

What is the correct syntax for replacing the literal string, "MyVar," with a
variable?
I've tried every way I could think of, and I always get a syntax error as
the result.

For instance:

Dim MyVariable as String
recordset.Find "FIELD = MyVariable"

does not work.

TIA,
Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default ADO's Find method (once again.)

Hi Mike,

In this example:

recordset.Find "FIELD = 'MyVar'"

What is the correct syntax for replacing the literal string, "MyVar," with

a
variable?
I've tried every way I could think of, and I always get a syntax error as
the result.


A workaround is to fully specify the argument in advance, e.g.

Dim str As String
' if MyVar is a String:
str = Chr(34) & "Field ='" & Chr(34) & MyVar & Chr(34) & "'" & Chr(34)
' if MyVar is numeric:
str = Chr(34) & "Field ='" & MyVar & "'" & Chr(34)
rs.Find str

HTH,
Merjet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default XL2K: ADO's Find method (once again.)

I don't know if this will work, but try

"FIELD = '" & MyVariable & "'"

or, a trick that I often use

recordset.Find Replace("FIELD = 'MyVar'", "MyVar", MyVariable)


On Thu, 29 Jul 2004 14:11:28 -0400, "Mike Mertes"
wrote:

Maybe no one understood what I was asking before, so let me try this again:

In this example:

recordset.Find "FIELD = 'MyVar'"

What is the correct syntax for replacing the literal string, "MyVar," with a
variable?
I've tried every way I could think of, and I always get a syntax error as
the result.

For instance:

Dim MyVariable as String
recordset.Find "FIELD = MyVariable"

does not work.

TIA,
Mike


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Find method wade Excel Programming 3 March 3rd 04 07:05 AM
Find method example Shinichi Excel Programming 3 August 22nd 03 10:39 PM
Help with the Find method Mike NG Excel Programming 3 August 4th 03 07:15 PM
The Find Method Dick Kusleika Excel Programming 3 July 16th 03 07:59 PM
The Find Method Brad[_7_] Excel Programming 0 July 16th 03 03:23 PM


All times are GMT +1. The time now is 07:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"