amol kadam
amol kadam

Reputation: 119

Cast string data type to Int in SQL QUery for MS Access

I am trying to write a query in access that will pull results that are in the database in a text Acually,I have RECEIPTNO Column whose datatype is TEXT in Table Membership, & I want to pull all the results from RECEIPTNO column where RECEIPTNO is BETWEEN 1 AND 10

And I tried Below Code.

SELECT Cint(RECEIPTNO) FROM MEMBERSHIP where Cint(RECEIPTNO) BETWEEN 1 AND 10

Result is: Overflow , Any Idea?

Upvotes: 5

Views: 52426

Answers (3)

OpeBams
OpeBams

Reputation: 21

This gives you what you want. ss

SELECT RECEIPTNO FROM MEMBERSHIP
WHERE Val(RECEIPTNO & "") BETWEEN 1 AND 10

Others using Val(RECEIPTNO) will only TRY to work somehow half-heartedly where it does beacuse the system doesn not recognise the RECEIPTNO as text and so, it is funny to it to see you passing a number instead of a string. However, to convince the system that the format is actually a number, concatenate it with an empty string which I have done.

Upvotes: 2

Fionnuala
Fionnuala

Reputation: 91376

Do you want:

SELECT RECEIPTNO FROM MEMBERSHIP
WHERE Val(RECEIPTNO) BETWEEN 1 AND 10

Upvotes: 5

amol kadam
amol kadam

Reputation: 119

Ohhh I got the answer, & it's working

& the Query Like

SELECT Cint(RECEIPTNO) FROM MEMBERSHIP where RECEIPTNO BETWEEN 1 AND 10

Upvotes: 3

Related Questions