Results 1 to 3 of 3

Thread: How to convert the data type between Word table and Access table?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    29

    Red face How to convert the data type between Word table and Access table?

    Hello

    I am sure that some body must know how to do it. I am going to transfer data in Word table into Access table, however the data type in one of the Access field is Number, I have to convert the data in Word into number so that the type does not mismatch. The part of code as:

    Set rs = dbs.OpenRecordset("Action", dbOpenDynaset)
    With rs
    .Addnew

    !ActionID = TrsTable.Cell(i, 1)


    The ActionID is the field name in Database table Action, the type is Number

    I tried !ActionID=CInt(TrsTable.Cell(i, 1)), it does not work.

    Any help please?

    Thank you

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    The table cell range will include the paragraph mark (or cell mark, or whatever that little box is at the end of each cell). Anyway, the string has that extra chracter in it making the cell range non-numeric. You coul use the Val function if tere ae no commas in the number, but you might be better off just trimming that extra character ad converting to a number (integer, long, or single if you need larger numers with decimal places.

    VB Code:
    1. !ActionID = CSng(Left$(TrsTable.Cell(i, 1).Range, Len(TrsTable.Cell(i, 1).Range) - 1))

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    Hi WorkHorse

    I tried use index to make it work before I received your reply.

    !ActionID= TrsTable.Cell(i - 1, 1).RowIndex

    It works, however I know this is not a good solution.

    You are absolutely right. I noticed two little boxes are at the end of each row in my Access table after tranfering from Word, I tried to trim it by using

    Left(TrsTable.Cell(i, 1), Len(TrsTable.Cell(i, 1)) - 2))

    but it does not work, now I understand that I missed "Range" Object.

    Your code is working perfectly. Thank you very much!

    Claire

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