Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    10

    Unanswered: Need Vb-access-dbase Expert Re:512 Char

    I have a big problem accessing dbf file from VB.

    i have a dbase .dbf file with MANY fields. one of them is a 512 char field (REMARKS).
    when a new ACCESS table is linked to it, the datatype shown (in design view) is TEXT with ZERO (0) length.

    when the dbf file is opened directly from VB, the remarks field value is NULL.

    I need VB to be able to read that file WITH the correct REMARKS data.

    PLEASE PLEASE HELP!!!
    thank you

    p.s. zipped sample dbf file is attached. The REMARKS field is about 4th from the last field in the table structure
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2004
    Posts
    142
    I do not know which version of Access you are using but text fields cannot go over 255. You could setup an import spec that specifies this field as a memo type. This would require using a local table to import into. If you need this field then this might be what you need to do.
    KC

  3. #3
    Join Date
    Mar 2004
    Posts
    10

    Need REMARKS field. It's very important.

    I don't quite understand you reply. Can I do what you propose with VB?
    Thanks

  4. #4
    Join Date
    Mar 2004
    Posts
    10

    VB code I am using to read dbf directly:

    Dim dbpath As String
    dbpath = "C:\Program Files\WYLDFYRE\WYLDFYRE 6\DB\"
    Dim DBFConn As New ADODB.Connection
    Dim lstg As New ADODB.Recordset

    With DBFConn
    .ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" _
    & dbpath
    .CursorLocation = adUseClient
    .Open
    DoEvents
    With lstg
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .ActiveConnection = DBFConn
    .source = "SELECT mlsno, remarks FROM class1"
    .Open
    '//If your just reading it you can remove the connection to save resources
    .ActiveConnection = Nothing
    DoEvents
    End With
    End With
    Do Until lstg.EOF
    ' lstg!remarks is null
    Loop

  5. #5
    Join Date
    Mar 2004
    Posts
    10
    Originally posted by AZ KC
    I do not know which version of Access you are using but text fields cannot go over 255. You could setup an import spec that specifies this field as a memo type. This would require using a local table to import into. If you need this field then this might be what you need to do.
    I am trying to import the data from the dbf file to another access table. The problem I have now is that the linked table doesn't interpret the 512 char field correctly, thus defining it as 0 length text.

    i have posted the code I am using.
    Also the sample dbf file is posted.

  6. #6
    Join Date
    Feb 2004
    Posts
    142
    The only way I know how to setup an import spec is to do it manually. In Access goto file -> Get External Data -> Link Tables.

    You will be prompted to select the file then a wizard will pop up to set up the link parameters. Click advanced and there you can specify the field types to use. Once the spec is setup the first time, save it with a name you can remember. Then you can goto code to open files and import them.

    This command is:
    DoCmd.TransferText acImportDelim, "Your Spec Name", _
    "Destination Table Name", "C:\Txtfiles\Your.doc"

    I am not sure if you can do this if you are using Visual Basic outside of Access. And dbf Files can be a little different.
    KC

  7. #7
    Join Date
    Mar 2004
    Posts
    10
    Originally posted by AZ KC
    The only way I know how to setup an import spec is to do it manually. In Access goto file -> Get External Data -> Link Tables.

    You will be prompted to select the file then a wizard will pop up to set up the link parameters. Click advanced and there you can specify the field types to use. Once the spec is setup the first time, save it with a name you can remember. Then you can goto code to open files and import them.

    This command is:
    DoCmd.TransferText acImportDelim, "Your Spec Name", _
    "Destination Table Name", "C:\Txtfiles\Your.doc"

    I am not sure if you can do this if you are using Visual Basic outside of Access. And dbf Files can be a little different.
    Thanks. I've linked already and access has a problem with the 512 char field in dbf file. Therein lies the whole problem.

Posting Permissions

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