Numeric variable in a SQL statement

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top