Numeric variable in a SQL statement

G

Guest

I am getting a errror of mismatching type in a SQL.
My searchinf field is long interger (primary key) and I couldn't find how to
pass it as numeric variable to the SQL statement. It is assuming always
assuming it as text.

I tried already the following, statements w/o sucess:

notes: getID is a long variable (which store the value of a control in a
form - (see next)
ShowIDtoChange is a control in a form

Statments tried:

Set rst = dbs.OpenRecordset("SELECT T_ListToReclass.IDCOP FROM
T_ListToReclass WHERE
(((T_ListToReclass.IDCOP)=[Forms]![F_Main]![ShowIDtoChange]));

'Set rst = dbs.OpenRecordset("SELECT T_ListToReclass.IDCOP FROM
T_ListToReclass WHERE
(((T_ListToReclass.IDCOP)=[Forms]![F_Main]![ShowIDtoChange]));")

'Set rst = dbs.OpenRecordset("select * from T_ListToReclass Where IDCOP='" +
getID + "'", dbOpenDynaset)

'Set rst = dbs.OpenRecordset("select * from T_ListToReclass Where
IDCOP=getID", dbOpenDynaset)

Thanks in advance for your help.
Thanks
 
N

Nikos Yannacopoulos

Jack,

Try something like:

strSQL = "SELECT T_ListToReclass.IDCOP FROM T_ListToReclass"
strSQL = strSQL & " WHERE T_ListToReclass.IDCOP)="
strSQL = strSQL & [Forms]![F_Main]![ShowIDtoChange]
Set rst = dbs.OpenRecordset(strSQL)

HTH,
Nikos
 
G

Guest

Jack is a good friend and introduced me to this new group and proposed the
question in my behaft. Now I am a user also!!
Thanks Niko - your tip works perfectly.
See you around...:)
Lippi
 
N

Nikos Yannacopoulos

Lippi,

Glad it worked. Welcome to the NG's, I'm sure we'll hear more of you.

Regards,
Nikos
Jack is a good friend and introduced me to this new group and proposed the
question in my behaft. Now I am a user also!!
Thanks Niko - your tip works perfectly.
See you around...:)
Lippi

:

I am getting a errror of mismatching type in a SQL.
My searchinf field is long interger (primary key) and I couldn't find how to
pass it as numeric variable to the SQL statement. It is assuming always
assuming it as text.

I tried already the following, statements w/o sucess:

notes: getID is a long variable (which store the value of a control in a
form - (see next)
ShowIDtoChange is a control in a form

Statments tried:

Set rst = dbs.OpenRecordset("SELECT T_ListToReclass.IDCOP FROM
T_ListToReclass WHERE
(((T_ListToReclass.IDCOP)=[Forms]![F_Main]![ShowIDtoChange]));

'Set rst = dbs.OpenRecordset("SELECT T_ListToReclass.IDCOP FROM
T_ListToReclass WHERE
(((T_ListToReclass.IDCOP)=[Forms]![F_Main]![ShowIDtoChange]));")

'Set rst = dbs.OpenRecordset("select * from T_ListToReclass Where IDCOP='" +
getID + "'", dbOpenDynaset)

'Set rst = dbs.OpenRecordset("select * from T_ListToReclass Where
IDCOP=getID", dbOpenDynaset)

Thanks in advance for your help.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top