Go Back   Velocity Reviews > Newsgroups > MCSD
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

MCSD - SQL Question Again - (hit enter and sent first attempt)

 
Thread Tools Search this Thread
Old 09-18-2004, 08:29 AM   #1
Default SQL Question Again - (hit enter and sent first attempt)


Trying to create a search string to handle searching within an MSAccess TEXT
field. Having problems when the variable is numeric
Tried: (spaces expanded for clarity)

strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' " - raised an error
when vVariable is numeric

tried testing for numeric value first:
if IsNumeric(vVariable) then
strWhere = strFieldName & "=" & val(vVariable)
else
strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' "
end if

This also didn't work. What's the work around on this?
Thanks in advance for any help offered
Owen Schwer



=?Utf-8?B?U29mdFNwb3Q=?=
  Reply With Quote
Old 09-18-2004, 04:48 PM   #2
 
Posts: n/a
Default Re: SQL Question Again - (hit enter and sent first attempt)
Post question of this sort to the following:
microsoft.public.access.queries
microsoft.public.vb.general.discussion
WKidd

"SoftSpot" <> wrote in message
news:C786FF24-4AD6-4293-BBBD-...
> Trying to create a search string to handle searching within an MSAccess

TEXT
> field. Having problems when the variable is numeric
> Tried: (spaces expanded for clarity)
>
> strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' " - raised an

error
> when vVariable is numeric
>
> tried testing for numeric value first:
> if IsNumeric(vVariable) then
> strWhere = strFieldName & "=" & val(vVariable)
> else
> strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' "
> end if
>
> This also didn't work. What's the work around on this?
> Thanks in advance for any help offered
> Owen Schwer
>





  Reply With Quote
Old 09-18-2004, 05:14 PM   #3
Tom Dacon
 
Posts: n/a
Default Re: SQL Question Again - (hit enter and sent first attempt)
For numeric values, it's:
strWhere = strFieldName & "=" & cstr(vVariable)
you want it come out something like:
WHERE Price = 12

for string values, you need to enclose the string in single-quotes, so it:
strWhere = strFieldName & "= ' " & vVariable & " ' "
you want it to come something like:
WHERE State = 'Washington'

There are better places than this to post programming questions, especially
something like a question about an SQL query. Microsoft has many newsgroups
that are devoted to programming subtopics. Why on earth would you post this
to a newsgroup that's dedicated to Microsoft MCSD certification instead of
one of those?

Tom Dacon
Dacon Software Consulting


"SoftSpot" <> wrote in message
news:C786FF24-4AD6-4293-BBBD-...
> Trying to create a search string to handle searching within an MSAccess

TEXT
> field. Having problems when the variable is numeric
> Tried: (spaces expanded for clarity)
>
> strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' " - raised an

error
> when vVariable is numeric
>
> tried testing for numeric value first:
> if IsNumeric(vVariable) then
> strWhere = strFieldName & "=" & val(vVariable)
> else
> strWhere = strFieldName & "= ' " & cstr(vVariable) & " ' "
> end if
>
> This also didn't work. What's the work around on this?
> Thanks in advance for any help offered
> Owen Schwer
>





Tom Dacon
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46