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




IT Certification FAQ

 
|
Home
|
Microsoft
|
CISCO
|
CompTIA
|
Exam/Study FAQ
|
Employment FAQ
| Links  | Forums  |
Book Reviews


FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  ProfileProfile  Log in to check your private messagesPrivate messages  Log inLog in

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

 
Post new topic   Reply to topic    Forum Index -> microsoft.public.cert.exam.mcsd
Author Message
SoftSpot
Guest





PostPosted: Sat Sep 18, 2004 8:30 am    Post subject: SQL Question Again - (hit enter and sent first attempt) Reply with quote

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
Back to top
Guest






PostPosted: Sat Sep 18, 2004 4:30 pm    Post subject: Re: SQL Question Again - (hit enter and sent first attempt) Reply with quote

Post question of this sort to the following:
microsoft.public.access.queries
microsoft.public.vb.general.discussion
WKidd

"SoftSpot" <SoftSpot@discussions.microsoft.com> wrote in message
news:C786FF24-4AD6-4293-BBBD-C5F58E5DBBA5@microsoft.com...
Quote:
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
Back to top
Tom Dacon
Guest





PostPosted: Sat Sep 18, 2004 4:30 pm    Post subject: Re: SQL Question Again - (hit enter and sent first attempt) Reply with quote

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" <SoftSpot@discussions.microsoft.com> wrote in message
news:C786FF24-4AD6-4293-BBBD-C5F58E5DBBA5@microsoft.com...
Quote:
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> microsoft.public.cert.exam.mcsd All times are GMT
Page 1 of 1

 

Copyright © 2002-2006 Web-S-Sense Pty. Ltd. All rights reserved.

Powered by phpBB
Advertising | Policies/Disclaimers | Contact us | Link to us


Featured Sites: Free Antivirus and Antispyware Info | Free PC Support | MCSE Directory