|
-
Oct 21st, 2003, 10:06 AM
#1
Thread Starter
Junior Member
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
-
Oct 22nd, 2003, 06:32 PM
#2
Fanatic Member
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:
!ActionID = CSng(Left$(TrsTable.Cell(i, 1).Range, Len(TrsTable.Cell(i, 1).Range) - 1))
-
Oct 28th, 2003, 10:27 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|