Solved

field size

Posted on 1998-09-07
3
208 Views
Last Modified: 2012-05-04

Why this is not running?
Notes:"art_descricao" is a field of the artigos table.

dim val

 MyFile = "C:\desenvolvimento\vbasic\winges\clientes.MDB"
Set MyWorkspace = Workspaces(0)
    Set MyDatabase = MyWorkspace.OpenDatabase(MyFile, False, False)
       Set MySet = MyDatabase.OpenRecordset("artigos", dbOpenDynaset)

--->>>> val = myset.fields("art_descricao").FieldSize ???????<<-----

msgbox (val)


thanks
0
Comment
Question by:asimoes
3 Comments
 

Expert Comment

by:DaveD072798
ID: 1433452
What type of field is "art_descricao"? FieldSize will only work on Long Binary and Memo fields. You use Size instead of FieldSize for anything else.
0
 
LVL 7

Expert Comment

by:tward
ID: 1433453
DaveD is correct, what is the error you are getting?

FieldSize Property

Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field object in the Fields collection of a Recordset object.

Return Values

The return value is a Long that indicates the number of characters (for a Memo field) or the number of bytes (for a Long Binary field).

Remarks

You can use FieldSize with the AppendChunk and GetChunk methods to manipulate large fields.

Because the size of a Long Binary or Memo field can exceed 64K, you should assign the value returned by FieldSize to a variable large enough to store a Long variable.

To determine the size of a Field object other than Memo and Long Binary types, use the Size property.

Note In an ODBCDirect workspace, the FieldSize property is not available in the following situations:

If the database server or ODBC driver does not support server-side cursors.


If you are using the ODBC cursor library (that is, the DefaultCursorDriver property is set to dbUseODBC, or to dbUseDefault when the server does not support server-side cursors).


If you are using a cursorless query (that is, the DefaultCursorDriver property is set to dbUseNoCursor).
For example, Microsoft SQL Server version 4.21 does not support server-side cursors, so the FieldSize property is not available.

The FieldSize property and the VBA Len() or LenB() functions may return different values as the length of the same string. Strings are stored in a Microsoft Jet database in multi-byte character set (MBCS) form, but exposed through VBA in Unicode format. As a result, the Len() function will always return the number of characters, LenB will always return the number of characters X 2 (Unicode uses two bytes for each character), but FieldSize will return some value in between if the string has any MBCS characters. For example, given a string consisting of three normal characters and two MBCS characters, Len() will return 5, LenB() will return 10, and FieldSize will return 7, the sum of 1 for each normal character and 2 for each MBCS character.

0
 
LVL 2

Accepted Solution

by:
dabellei earned 50 total points
ID: 1433454
Like Daved said you should use the size instead of Fieldsize if your fields is not memo or long binary field. Also you can't use val = .....  val is a reserved word in VB.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now