#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Brazil
    Posts
    8
    Rep Power
    0

    Talking Accessing memo fields in a DBF


    Hi, guys

    How can i access memo fields in a DBF using a VB aplication

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2003
    Posts
    1,152
    Rep Power
    13
    Use DAO or ADO to access MSaccess files..add ms dao control into your project..
    U can visit the msdn web:http://msdn.microsoft.com/library/de..._adorosest.asp
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Brazil
    Posts
    8
    Rep Power
    0

    ADO/DAO


    Cleverpig, i can to access .mdb tables using DAO or ADO, be cool, my problem is just how can i access .DBF tables that have memo fields using ADO

    Thanks.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2003
    Posts
    1,152
    Rep Power
    13
    OK! U will access DBF file??..
    This is a way:
    1. Create connection to open DBF files
    We can use several providers to open DBF files usind ADODB. Basic way is to use ODBC data source (DSN or DSNless), there is several samples published on web. But how to open DBF files without ODBC? There are two other OLEDB providers, using which you can work with DBF files. One of them is Microsoft.Jet.OLEDB.
    Key property to work with DBF files is "Extended Properties" - there is no much info about this parameter in documentation. This parameter has similar meaning as connect parameter in DAO OpenDatabase method. First work is to open connection to DBASE IV files:
    Function OpenDBFConn(Path)
    Dim Conn: Set Conn = CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Path & ";" & _
    "Extended Properties=""DBASE IV;"";"
    Set OpenDBFConn = Conn
    End Function

    2. Other ISAM formats, FoxPro
    "DBASE IV" is one of ISAM format. You can find installed ISAM formats in

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\
    registry key. You can use other formats - "dBase 5.0", "Paradox 3.X", "Outlook 9.0" etc.
    But what about FoxPro files? Microsoft.Jet.OLEDB.4.0 does not support FoxPro 2.0 - 3.0 as ISAM parameter - you cannot see this ISAM engine in Jet\4.0\ISAM Formats lists. You can do some small work around of this feature - import FoxPro ISAM from Jet\3.5 key. Create small .reg file with the next information:

    REGEDIT4

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\FoxPro 3.0]
    "Engine"="Xbase"
    "ExportFilter"="Microsoft FoxPro 3.0 (*.dbf)"
    "CanLink"=hex:00
    "OneTablePerFile"=hex:01
    "IsamType"=dword:00000000
    "IndexDialog"=hex:00
    "CreateDBOnExport"=hex:00
    "ResultTextExport"="Export data into a Microsoft FoxPro 3.0 file."
    "SupportsLongNames"=hex:00


    Then you can use
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Path & ";" & _
    "Extended Properties=""FoxPro 3.0;"";"



    3. Work with DBF connection
    So, what we can do with the connection? You can use any ODBC statement (Create table, Insert Into, Delete, Select ...). You can address the table using several ways:

    Select * from Persons
    Select * from Persons.DBF
    Insert Into Persons#DBF Values (...)
    Delete * from [Persons.DBF] Where ...

    Create Table [Any Long File Name You Want] As ...


    4. Real VBS samples
    Open DBF connection, create table, insert records, get recordset.


    'Open connection For DBF files In F:\ folder
    Dim DBConn
    Set DBConn = OpenDBFConn("f:\")

    'Create a new DBF file named Persons.DBF
    DBConn.Execute "Create Table Persons (Name char(50), City char(50), Phone char(20), Zip decimal(5))"

    'Insert some row To the table
    DBConn.Execute "Insert into Persons Values('Alex P. Nor', 'Mexico','458962146','14589')"

    'Open recordset from Persons table
    Dim Persons
    Set Persons = DBConn.Execute("Select * from [Persons#DBF]")

    'Output the recordset In csv format
    Wscript.Echo Persons.GetString(,-1, ", ", vbCrLf)


    Plz Visit http://www.pstruh.cz/tips/detpg_asp-dbf-database.htm
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Brazil
    Posts
    8
    Rep Power
    0

    Memo fields in .DBF tables


    Cleverpig, thanks for your suggestion, but i have one more question: using that, can i really access .DBF tables that have MEMO fields ? Can i read datas from these fields using SQL statements (SELECT), for example ?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2003
    Posts
    1,152
    Rep Power
    13
    Yes u can do it,if u use recordset variable to get it.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    solution accessing memo fields from vba


    Hi,
    do you know how accessing to memo fields fpt from VBA ?
    thanks.

IMN logo majestic logo threadwatch logo seochat tools logo