Solved

field size

Posted on 1998-09-07
3
207 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

744 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

11 Experts available now in Live!

Get 1:1 Help Now