Results 1 to 5 of 5

Thread: Memo truncated via variant??

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Memo truncated via variant??

    Hi,

    I am using Access 2k, and I have a memo field. I am displaying it to the user in Access 2k via code and a listbox. The code uses variants to get data from the tables/array to the list box.

    I'vee stepped through the code and the correct full data is returned and stored in the array. But when this is put into a variant then returned via the listbox its truncated to 255 chars.

    Is there a string limit to the variant and if so how would I extend it to make the variant a proper string in these cases?

    Anyone come across this before?

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    Don't think the Variant is your problem Vince. Can't be sure, because I don't use them due to an irrational, pathological hatred of the things, but I'm pretty sure that a variant of string subtype can hold a memo field.

    Could it be the list box? When exactly do you the lose data?

  3. #3

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    I lose it when requesting it from the listbox.

    The code goes to the class module in which the array is and grabs the data returning it through a variant. Usually I don't use variant (same thing as you) but in this case is the coding given by a book on how to code an access listbox so that its
    a) not linked and
    b) not open whilst the form is open

    These reasons helped me use this method of list box (although sometimes there is a memory leak and access dies... even with 512mb of ram... hehe oh well)

    Anyway, back to the problem. Its a memo field in the table holding all the string data. Its transferred to the array fine, its just going through the calling sub using a variant. If you want I can post the function that is on the form (used by the list box) and the class module for you to see, poke your finger at and forget lol

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    Go on then - I'll see if I can see anything...
    I've just tried a little test, and got over 500 characters into and out of an Access listbox. So I'm stumped.

  5. #5

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    VB Code:
    1. Option Compare Database
    2. Option Explicit
    3.  
    4. '---- 24 July 2002
    5. '----   Adding in all simple look up tables to the shared mdb - and so I'm changing all  - yes all - the links via all the
    6. '----   screens so that they look here
    7. '----
    8. '---- 3 July 2002
    9. '----   Corrupted (shock horror!) and I mean really corrupted - not just one form but forms and coding
    10. '----
    11. '---- 18 Feb 2002
    12. '----   Beware corrupting dbs...
    13. '----
    14. '---- Feb 2002
    15. '----   Redoing Access 97
    16. '----   heheh
    17.  
    18. '---- 25 May 2001
    19. '---- For my next trick I shall reconvert it all back to dao 97...
    20. '----
    21. '---- 08/03/2001 - 17/03/2001 (St Pats day!)
    22. '---- converted to Access 2k - including changing the references to ado...
    23. '---- fun...
    24. '---- btw - this is likely to eat memory - but generally 'feels' better.
    25. '---- BUT does allow changing of the tables whilst users have them open... Sorta
    26. '---- this opens the table and grabs the information required then closes the table
    27. '---- The listbox combo to tables (faster) holds the tables open, which could stop development... My excuse not to use
    28. '---- Developer choice anyway
    29.  
    30. '---- 20/05/99 ----'
    31. '---- List box fillers... Do we have fun or what ?
    32.  
    33. '---- how to use
    34. '---- 1) set up a variable which points to this class module (must be global or form global so it's held open)
    35. '---- 2) set up the usual list box caller function (just the function name and args)
    36. '---- 3) set the control, varid, rows, cols and code to whichever
    37. '---- 4) set the code to run (mintF) (from 0 to how ever many code initializes)
    38. '---- 5) call 'returninfo' as a variant (returned)
    39. '---- 6) set and return this in your function call (like usual)
    40.  
    41. Private ctl As Control              '-The stuff from 'normal' list boxes
    42. Private varID As Variant
    43. Private mlngRow As Long
    44. Private mlngCol As Long
    45. Private mintCode As Integer
    46.  
    47. Private aColWidth() As Integer  '-array of widths
    48. Private aData() As String       '-array of data
    49. Private mintF As Integer         '-which code to fill ?
    50. Private mlngItems As Long        '-no of items
    51. Private mintC As Integer             '-columns
    52. Private mstrInfo As String           '- Extra info (search criteria? sql?)
    53. Private mblnUseHeader                'first line is header of listbox...
    54.  
    55.  
    56. Public Property Get aInfo() As String
    57.     aInfo = mstrInfo
    58. End Property
    59.  
    60. Public Property Let aInfo(ByVal strNew As String)
    61.     mstrInfo = strNew
    62. End Property
    63.  
    64. Public Property Get aControl() As Control
    65.     Set aControl = ctl
    66. End Property
    67.  
    68. Public Property Let aControl(ByVal ctlNew As Control)
    69.     Set ctl = ctlNew
    70. End Property
    71.  
    72. Public Property Get aIDVar() As Variant
    73.     aIDVar = varID
    74. End Property
    75.  
    76. Public Property Let aIDVar(ByVal varNew As Variant)
    77.     varID = varNew
    78. End Property
    79.  
    80. Public Property Get aRow() As Long
    81.     aRow = mlngRow
    82. End Property
    83.  
    84. Public Property Let aRow(ByVal lngNew As Long)
    85.     mlngRow = lngNew
    86. End Property
    87.  
    88. Public Property Get aCol() As Long
    89.     aCol = mlngCol
    90. End Property
    91.  
    92. Public Property Let aCol(ByVal lngNew As Long)
    93.     mlngCol = lngNew
    94. End Property
    95.  
    96. Public Property Get aCode() As Integer
    97.     aCode = mintCode
    98. End Property
    99.  
    100. Public Property Let aCode(ByVal intNew As Integer)
    101.     mintCode = intNew
    102. End Property
    103.  
    104. Public Property Get aFillWith() As Integer
    105.     aFillWith = mintF
    106. End Property
    107.  
    108. Public Property Let aFillWith(ByVal intNew As Integer)
    109.     mintF = intNew
    110. End Property
    111.  
    112. Public Property Let aHasHeader(ByVal blnNew As Boolean)
    113.     mblnUseHeader = blnNew
    114. End Property
    115.  
    116. Public Property Get aHasHeader() As Boolean
    117.     aHasHeader = mblnUseHeader
    118. End Property
    119.  
    120. Private Sub Class_Initialize()
    121.     ReDim aData(0, 0)
    122.     mlngItems = 0
    123.     mstrInfo = ""
    124. End Sub
    125.  
    126. Private Sub Class_Terminate()
    127. '---- clean out the array as you leave, please...
    128.     Erase aData
    129. End Sub
    130.  
    131.  
    132.  
    133. Public Function fReturnInfo() As Variant
    134.     Dim varRet As Variant
    135.    
    136.     Dim lngErr As Long, strErr As String
    137.     lngErr = Err.Number
    138.     strErr = Err.Description
    139.    
    140.     On Error Resume Next
    141.    
    142.     Select Case mintCode
    143.         Case acLBInitialize
    144.             ReDim aData(0, 0)
    145.             mlngItems = 0
    146.             mintC = 1
    147.             Select Case mintF
    148.                 Case 0
    149. '---- insert the list creater sub
    150. '---- included in the sub should be : (hint see those here already ? ;)
    151. '----   must make a list of values to be viewed (usual)
    152. '----   must set mintC (no of columns)
    153. '----   must set aColWidth() 's for each column
    154.                
    155.                 Case 1
    156.                     CustSearchList
    157.                 Case 2
    158.                     SalesEnquiriesFilteredList
    159.                    
    160.                 Case 10
    161.                     UsefulFoldersList
    162.                    
    163.                 Case 20
    164.                     SEActionsList
    165.                    
    166.                 Case 25
    167.                     PlatformsList
    168.                 Case 26
    169.                     VehicleLUList
    170.                    
    171.                 Case 100
    172.                     zLUSimple "Titles"
    173.                 Case 101
    174.                     zLUSimple "SEAct"
    175.  
    176. '---- Lookups - Shared
    177.                
    178.             End Select
    179.             varRet = True
    180.         Case acLBOpen
    181.             varRet = Timer
    182.         Case acLBGetColumnCount
    183.             varRet = mintC
    184.         Case acLBGetRowCount
    185.             varRet = mlngItems
    186.         Case acLBGetColumnWidth
    187.             If mlngCol > 0 Then
    188.                 varRet = aColWidth(mlngCol)
    189.             Else
    190.                 varRet = 0
    191.             End If
    192.         Case acLBGetValue
    193.             varRet = aData(mlngRow, mlngCol)
    194.         Case acLBGetFormat
    195.             varRet = Null
    196.     End Select
    197.     fReturnInfo = varRet
    198.     If Not lngErr = 0 Then Err.Raise lngErr, , strErr
    199. End Function
    200.  
    201. '---- this is the function which MUST be put on the forms code
    202. '---- you need to copy it there, change the function name, type the new name into the list/combo data field instead of table/query
    203. '---- delete the 'Dim lbinf As New clsLists' and change '.afillwith' to the correct number
    204. Function Fill(ctl As Control, varID As Variant, mlngRow As Long, mlngCol As Long, mintCode) As Variant
    205.     Dim varRetval As Variant
    206.     Dim lbinf As New clsListShared
    207.     Dim lngErr As Long, strErr As String
    208.    
    209.     If Not Err.Number = 0 Then
    210.         lngErr = Err.Number
    211.         strErr = Err.Description
    212.     End If
    213.    
    214.     On Error Resume Next
    215.     Err.Clear
    216.    
    217.     With lbinf
    218.         .aControl = ctl
    219.         .aIDVar = varID
    220.         .aCol = mlngCol
    221.         .aRow = mlngRow
    222.         .aCode = mintCode
    223.         .aHasHeader = True
    224.         .aFillWith = 0
    225.         .aInfo = ""
    226.         varRetval = .fReturnInfo
    227.     End With
    228.    
    229.     Fill = varRetval
    230.    
    231.     If Not lngErr = 0 Then Err.Raise lngErr, , strErr
    232.    
    233. End Function

    Thats the class... The subs that it calls put data into the adata() array.

    The function is the standard template one I use on the form. Renamed of course, before use with the combo/listbox.

    Perhaps its the way I'm doing it.

    When you tested was it via code (unbound) or bound?


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width