Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem iwth CInt

Status
Not open for further replies.

RamziSaab

MIS
May 7, 2003
522
GB
I wrote the following code which basically rounds my tables i selec tto the nearest interger. It works for the most part except that it changes some of the data to blanks...i have tried it a few times always does it. The data is numeric so i dont understand why it selects what seems to be random data and deletes the cell.... anyone know?

Private Sub RunRemoveDecimal_Click()
On Error GoTo Err_RunRemoveDecimal
Dim strSQL As String
Dim strSelect As String

For i = 0 To lstField.ListCount - 1
strSelect = strSelect & "[" & Me!cboTable & "].[" & lstField.Column(0, i) & "] = (CInt([" & lstField.Column(0, i) & "]*1))/1,"
Next i

strSQL = "Update [" & Me!cboTable & "] Set " & Left(strSelect, Len(strSelect) - 1)
MsgBox strSQL
DoCmd.RunSQL (strSQL)

Exit_RunRemoveDecimal_Click:
Exit Sub

Err_RunRemoveDecimal:
MsgBox Err.Description
Resume Exit_RunRemoveDecimal_Click

End Sub
 
By the way when i use the same formula but with Clng instead of cint it seems to work fine?

Anyone have an explanantion?
 
By the way it does come up with Type conversion errors but i dont understand why...considering they are all numeric fields? The CLNG gives no errrs...what is the difference
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top