Select Problem

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

Guest

I am trying to select a single record based on a code. The code in the table
is 4 characters defined as text, though all the values are numeric at
present. I define a text box on a form, and use the value entered in the box
to select the record. I always get a type mismatch error. I changed the
type of the field in the table to integer and ran the select again and it
worked. However, this field may not always be numeric in the future so I
don't want to define it as an integer. Why is this happening?
 
You should give us the SQL string itself. Without that, I can only guess
that you left out the quotes in the SQL string. For example, you used:

SELECT *
FROM t_Table
WHERE Code=1234

Instead of

SELECT *
FROM t_Table
WHERE Code="1234"

If you are using an Access database, you need double-quotes. In others,
including SQL_SERVER, you need single quotes.

Putting double quotes into a VB statement is a little difficult. You need
something like this:

dim Code as string
dim Text as string

Code = "1234"
Text = "This is """ + code + """"

Notice in the last line there is <1 double quote>, <3 double quotes>, <4
double quotes>

Hope this helps,
Dom

--
Dominic Olivastro
ipIQ, Inc.

web: http://www.ipIQ.com
fax: 1-856-546-9633
voice: 1-856-546-0600 (ext 224)
email: (e-mail address removed)
 
Back
Top