cyberbiker
Programmer
Well, looks like I have another problem with the basics.
As I have said, I am converting an app from jet and ACCESS 97 to ADO and SQL Server (MSDE).
I am becoming confused on the different data types and constants. The following function currently exists:
Public Sub bsSizeToDb(fld As Field, size As Variant, Optional ByVal lcd As Boolean = True)
'--- Converts <size> (type Null or Double) to database field <fld>
If fld Is Nothing Then ERR.Raise 911, , "Database doesn't contain size field"
If IsNull(size) Or IsEmpty(size) Then
fld.value = Null
ElseIf VarType(size) <> vbDouble Then
GoTo badtype
Else
If bpDbMetric Then size = size * 25.4
Select Case fld.Type
'Case dbDouble, dbSingle, dbFloat, dbInteger, dbLong, dbDecimal, dbNumeric 'this line I commented out and replaced with the next line
Case adBigInt, adDouble, adInteger, adSingle, adSmallInt, adTinyInt, adDecimal, adNumeric 'this line is my best guess as to what I should do instead
fld.value = size
Case dbMemo
'What do I do with this??????
fld.value = bfLCDString(size, lcd)
Case dbChar, dbText
Dim maxlen As Long, txt As String
txt = bfLCDString(size, lcd And Not bpDbMetric)
maxlen = fld.size
If maxlen = 0 Then maxlen = 255
If Len(txt) > maxlen Then
'--- String doesn't fit in field, trimming works if not LCD
If bpDbMetric And lcd Then ERR.Raise 911, , "Size doesn't fit in database field '" & fld.name & "'"
txt = Left$(txt, maxlen)
End If
fld.value = txt
Case Else
GoTo badtype
End Select
End If
Exit Sub
badtype:
ERR.Raise 911, , "Cannot convert size to database field '" & fld.name & "'"
End Sub
When I read help and my books, it looks as if advarChar is the needed replacement for a memo field except that help says it is for parameters only.
When I converted the ACCESS tables, many of the text fields were converted as varChar. How can this be if the constant advarchar is only for parameters? Or what am I missing?
BTW, no "memo" field currently exists in the ACCESS 97 tables. This function is for a planned future change. So I do have some flexibility Terry (cyberbiker)
As I have said, I am converting an app from jet and ACCESS 97 to ADO and SQL Server (MSDE).
I am becoming confused on the different data types and constants. The following function currently exists:
Public Sub bsSizeToDb(fld As Field, size As Variant, Optional ByVal lcd As Boolean = True)
'--- Converts <size> (type Null or Double) to database field <fld>
If fld Is Nothing Then ERR.Raise 911, , "Database doesn't contain size field"
If IsNull(size) Or IsEmpty(size) Then
fld.value = Null
ElseIf VarType(size) <> vbDouble Then
GoTo badtype
Else
If bpDbMetric Then size = size * 25.4
Select Case fld.Type
'Case dbDouble, dbSingle, dbFloat, dbInteger, dbLong, dbDecimal, dbNumeric 'this line I commented out and replaced with the next line
Case adBigInt, adDouble, adInteger, adSingle, adSmallInt, adTinyInt, adDecimal, adNumeric 'this line is my best guess as to what I should do instead
fld.value = size
Case dbMemo
'What do I do with this??????
fld.value = bfLCDString(size, lcd)
Case dbChar, dbText
Dim maxlen As Long, txt As String
txt = bfLCDString(size, lcd And Not bpDbMetric)
maxlen = fld.size
If maxlen = 0 Then maxlen = 255
If Len(txt) > maxlen Then
'--- String doesn't fit in field, trimming works if not LCD
If bpDbMetric And lcd Then ERR.Raise 911, , "Size doesn't fit in database field '" & fld.name & "'"
txt = Left$(txt, maxlen)
End If
fld.value = txt
Case Else
GoTo badtype
End Select
End If
Exit Sub
badtype:
ERR.Raise 911, , "Cannot convert size to database field '" & fld.name & "'"
End Sub
When I read help and my books, it looks as if advarChar is the needed replacement for a memo field except that help says it is for parameters only.
When I converted the ACCESS tables, many of the text fields were converted as varChar. How can this be if the constant advarchar is only for parameters? Or what am I missing?
BTW, no "memo" field currently exists in the ACCESS 97 tables. This function is for a planned future change. So I do have some flexibility Terry (cyberbiker)