docmd.openform where clause doesn't work if search string is a num

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I am using docmd.openform to launch a form (passed in the where clause).
It works most of the time, EXCEPT when the search string is a number, then it
won't return anything. Here is the code:

strTemp = InputBox("Look for", "Search")

If Len(strTemp) > 0 Then DoCmd.OpenForm "FrmSearchResults", acFormDS, ,
"[Comments]like '*" & strTemp & "*'"


the strangest thing is if I look for "1" and if there's a record w/ test1
it'll return the record. But if the record is test 1, it would return
anything.

Thnaks
 
roger,
switching data type doesn't make any different. Just like before, it'd
returns records Test1 but not test 1. I think more or less it has sth to do
with my where clause.

Thx

Roger Carlson said:
Is strTemp declared as a String? Like this:

Dim strTemp as String

If you just have:

Dim strTemp

It was created as a variant and it will hold an actual number rather than
the string representation of the number.


--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Jeff said:
Hi all,
I am using docmd.openform to launch a form (passed in the where clause).
It works most of the time, EXCEPT when the search string is a number, then it
won't return anything. Here is the code:

strTemp = InputBox("Look for", "Search")

If Len(strTemp) > 0 Then DoCmd.OpenForm "FrmSearchResults", acFormDS, ,
"[Comments]like '*" & strTemp & "*'"


the strangest thing is if I look for "1" and if there's a record w/ test1
it'll return the record. But if the record is test 1, it would return
anything.

Thnaks
 
Back
Top