numeric value and string

I

Iona

okay.. this should be long..

I made up a table in database with access consists of columns with text type. Some of them I put in data with numeric value and some of them I put in "Unlimited" as the value.

Then, I allowed people to insert data but only with conditions. They can insert data if the value they are trying to insert is smaller than the one in the database. For "unlimited" value, they can insert any value.

My problem is.... if the limited value in the database is 35, we cant insert data of 40 but we can insert data of 100. It seems that the code only takes the first number to be compared to the value in the database.

Can anyone help me to overcome this?

here''s part of my code

If (diff = 0) OR (diff = 1) Then
If (maxunit1 < strnoofunit) OR (maxdoc1 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End If
ElseIf (diff = 2) Then
If (maxunit2 < strnoofunit) OR (maxdoc2 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End If
ElseIf (diff = 3) Then
If (maxunit3 < strnoofunit) OR (maxdoc3 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End if
ElseIf (diff = 4) Then
If (maxunit4 < strnoofunit) OR (maxdoc4 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End If
ElseIf (diff = 5) Then
If (maxunit5 < strnoofunit) OR (maxdoc5 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End If
Else
If (maxunit6 < strnoofunit) OR (maxdoc6 < strnoofdoc) Then
rs2.close
conn.close
set rs2 = nothing
set conn = nothing
Server.Transfer("maxunit2.asp")
End If
End If

'' -------------------------------------------------------------------------
'' finish
'' -------------------------------------------------------------------------
rs.Open "SELECT * FROM timesheet", conn, 3, 3
''Add a record
rs.AddNew
''Put username and password in record
rs("memberid") = Session("memberid")
rs("reference_no") = strrefno
rs("entry_date") = date()
rs("lspid") = Session("lspid")
rs("solicitorid") = Session("solid")
rs("code") = strcode
rs("no_of_unit") = strnoofunit
rs("no_of_document") = strnoofdoc
rs("note_legalmatter")= strlegalmatter
rs("note_entitlement")= strentitle

''Save record
rs.Update

Thanks guys
 
H

Hal Rosser

Iona said:
okay.. this should be long..

I made up a table in database with access consists of columns with text
type. Some of them I put in data with numeric value and some of them I put
in "Unlimited" as the value.
Then, I allowed people to insert data but only with conditions. They can
insert data if the value they are trying to insert is smaller than the one
in the database. For "unlimited" value, they can insert any value.
My problem is.... if the limited value in the database is 35, we cant
insert data of 40 but we can insert data of 100. It seems that the code only
takes the first number to be compared to the value in the database.
Can anyone help me to overcome this?

If your data is brought in as a string, you need to cast it to a number to
be able to compare it numerically.
when you compare strings, it looks at the characters - not the actual
numbers.
f'rinstance:
If isNumeric(strVariableName) then
dim intTemp as Double= System.Convert.ToDouble(strVariableName)
etc
 
R

Ray Costanzo [MVP]

Don't store numeric data as text.

I'm not sure what your code is supposed to be doing, but if you're doing the
comparison in your code (as opposed to in a SQL [non]query), you can CInt
the values to compare them. You can also do that in the query.

iCurrentValue = yourRecordset.Fields.Item("yourColumn").Value
If iCurrentValue <> "Unlimited" Then
If CInt(iNewValue) > CInt(iCurrentValue) Then
''your code
End If
End If

Ray at work



Iona said:
okay.. this should be long..

I made up a table in database with access consists of columns with text
type. Some of them I put in data with numeric value and some of them I put
in "Unlimited" as the value.
Then, I allowed people to insert data but only with conditions. They can
insert data if the value they are trying to insert is smaller than the one
in the database. For "unlimited" value, they can insert any value.
My problem is.... if the limited value in the database is 35, we cant
insert data of 40 but we can insert data of 100. It seems that the code only
takes the first number to be compared to the value in the database.
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top