VarChar to Integer

A

Angel G

I have a field in a form that contains an integer value, but when I pass the
value of the field into a query I get an error stating that the value can
not be convereted from a varchar to an integer value. here is my query
SELECT DISTINCT
LotNumber, LotDescription, LotRevision,
VendorLotNumber, FirstReceiptDate, LastInspectionDate, LotExpirationDate,
ItemKey, LotTraceKey
FROM FSDBMR.dbo.FS_LotTrace
WHERE (LotTraceKey = '"&Me![LotNumber]&"')

basically
'"&Me![LotNumber]&"'
contains the passing value.
I have tried various ways but no luck.
Any help is appreciated.
 
B

Bob Quintal

I have a field in a form that contains an integer value, but when
I pass the value of the field into a query I get an error stating
that the value can not be convereted from a varchar to an integer
value. here is my query SELECT DISTINCT
LotNumber, LotDescription, LotRevision,
VendorLotNumber, FirstReceiptDate, LastInspectionDate,
LotExpirationDate, ItemKey, LotTraceKey
FROM FSDBMR.dbo.FS_LotTrace
WHERE (LotTraceKey = '"&Me![LotNumber]&"')

basically
'"&Me![LotNumber]&"'
contains the passing value.
I have tried various ways but no luck.
Any help is appreciated.
The message implies that LotTraceKey is type integer.

Where is the query?
You may also need to change the me! to Forms!Formname!
 
A

Angel G

This is the record source of a combobox inside the form (AMC_ResultsA).
I have also done the conversion of Me! to Forms![AMC_ResultsA]![LotNumber]
But no go.
The LotTraceKey field is numeric an the results in LotNumber are Numeric
(bound to a primary key field of Int value) but some how when I use
'"&![LotNumber]&"' or any other combination the results are considered
varchar type.
Bob Quintal said:
I have a field in a form that contains an integer value, but when
I pass the value of the field into a query I get an error stating
that the value can not be convereted from a varchar to an integer
value. here is my query SELECT DISTINCT
LotNumber, LotDescription, LotRevision,
VendorLotNumber, FirstReceiptDate, LastInspectionDate,
LotExpirationDate, ItemKey, LotTraceKey
FROM FSDBMR.dbo.FS_LotTrace
WHERE (LotTraceKey = '"&Me![LotNumber]&"')

basically
'"&Me![LotNumber]&"'
contains the passing value.
I have tried various ways but no luck.
Any help is appreciated.
The message implies that LotTraceKey is type integer.

Where is the query?
You may also need to change the me! to Forms!Formname!
 
B

Bob Quintal

This is the record source of a combobox inside the form
(AMC_ResultsA). I have also done the conversion of Me! to
Forms![AMC_ResultsA]![LotNumber] But no go.
The LotTraceKey field is numeric an the results in LotNumber are
Numeric (bound to a primary key field of Int value) but some how
when I use '"&![LotNumber]&"' or any other combination the results
are considered varchar type.

when you use '"&![LotNumber]&"' or any other combination you are
implicitly converting the number to a string.
WHERE LotTraceKey = clng(Forms![AMC_ResultsA]![LotNumber]) will
explicitly convert lot number to a long integer.

Q
Bob Quintal said:
I have a field in a form that contains an integer value, but
when I pass the value of the field into a query I get an error
stating that the value can not be convereted from a varchar to
an integer value. here is my query SELECT DISTINCT
LotNumber, LotDescription, LotRevision,
VendorLotNumber, FirstReceiptDate, LastInspectionDate,
LotExpirationDate, ItemKey, LotTraceKey
FROM FSDBMR.dbo.FS_LotTrace
WHERE (LotTraceKey = '"&Me![LotNumber]&"')

basically
'"&Me![LotNumber]&"'
contains the passing value.
I have tried various ways but no luck.
Any help is appreciated.
The message implies that LotTraceKey is type integer.

Where is the query?
You may also need to change the me! to Forms!Formname!
 

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