Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Find method | Excel Programming | |||
Find method example | Excel Programming | |||
Help with the Find method | Excel Programming | |||
The Find Method | Excel Programming | |||
The Find Method | Excel Programming |