When I get the size from RDO, is that giving me the bit size or the number of characters?
Main Topics
Browse All TopicsI am getting the record size using rdo in the following way..
intFieldSize = rdoConnect.rdoTables(tblNa
I am passing the size value to the function below to ensure that the element I want to insert into the database does not exceed the record size. However, many records are being prompted that they are too big, but they are still being inserted into the database? Am I doing something wrong? Is there a better way of doing this?
Thanks..
Public Function cmdTrimLength(strString As Variant, intSize As Long, intType As Integer) As String
Dim intTestStringLen As Integer
Dim intInteger As Integer
Trim (strString)
Select Case intType
Case intType = -6 Or intType = -2
intInteger = CInt(strString)
If Len(intInteger) > 1 Then
strString = Left$(strString, 1) ' SubString does not exceed recordLength
MsgBox "Field length too large!", vbCritical
End If
Case Else
If Len(strString) - 2 > intSize Then
strString = Left$(strString, intSize)
MsgBox "RECORD LENGTH WAS TOO BIG!", vbCritical
End If
End Select
cmdTrimLength = strString
End Function
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Ok.. that was my problem then.
I have to make sure my string does not exceed these datatypes and lengths:
VarChar - i already took care of
Smallint 2
int 4
dateTime 8
tinyint 1
bit 1
How do I take care of dateTime?
Do you think this might work inside my function for bit?
Select Case intType
Case -2
If intLength > 1 Then
If strString = "'NULL'" Then
strString = Replace(strString, "'NULL'", "0")
strString = Trim(strString)
intInteger = CInt(strString)
Else
strString = Left$(strString, intSize - 1) & "'"
End If
End If
'Thanks
My suspicion would be in you select case statement. You made a 'Case Else' but yet enclosed an if...then statement without procedures for ELSE. Chances there are values which do not amount to -6 or -2 but yet do not satisfy your IF condition. You give it some thought.
Just curious though... How come you doing your own validation rules through vb code? What database are you using? My suggestion is to have validation rules on the database level and just catch errors whenever it doesn't satisfy your validation rules(e.g. field size, data type, etc...).
change your line...
If strString = "'NULL'" Then
with...
If strString = vbNull Then
and line...
strString = Replace(strString, "'NULL'", "0")
with...
strString = Replace(strString, vbNull, "")
if vbNull doesnt work then substitute with vbNullString.
What Database are you using? Do you have to use RDO? Why not ADO?
CD
Business Accounts
Answer for Membership
by: CD-SoftyPosted on 2003-05-23 at 10:40:50ID: 8573600
try changing this line...
intInteger = CInt(strString)
to...
intInteger = CInt(Len(strString))
I'm not sure what you're trying to achieve, but from your line of code here it seems you're trying to convert a variant to an integer, but that variant might well be a string, which will give you a 0 value.
CD