Lm th? no ? gi?i nn thng tin t? Excel t? v?i DAO

D?ch tiu ? D?ch tiu ?
ID c?a bi: 190195 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny


Tr?nh i?u khi?n Excel ISAM khng t? ?ng chuy?n ?i datatypes.


N?u c m?t c?t trong b?ng tnh Excel c?a b?n c ch?a c? hai vn b?n v s? i?n tho?i, ISAM s? khng th? ? gi?i thch m?t cch chnh xc m datatype n nn. ?m b?o r?ng t?t c? cc trong m?t c?t ?c ?nh d?ng ? l datatype cng. V d?, b?n c th? c sau d? li?u trong b?n c?t trong m?t b?ng Excel:
   male   female children teens
   11     cc     78       ee
   22     xx     33       ff
   45     uu     56       oo

N?u b?n c? g?ng ? ?c d? li?u thng qua cc tr?nh i?u khi?n ISAM ch?ng l?i cc t?m ton b?, b?n s? nh?n ?c cc gi tr? null cho d?ng ?u tin. N?u b?n mu?n trnh i?u ny, t?o ?c ?t tn theo d?y: m?t ch?a ch? l thng tin ?u th v khc c ch?a d? li?u thng tin. Vi du:
   named range 'myRange1' :
   male     female    children     teens

   named range 'myRange2' :
   11   cc   78   ee
   22   xx   33   ff
   45   uu   56   oo

By gi? b?n c th? k?t n?i v?i Excel v yu c?u thng tin ch? t? cc ?c bi?t l tn l ph?m vi. Tuy nhin, trong m?t ph?m vi, m?t c?t c? th? c th? ch?a ch? c m?t ki?u d? li?u.

Lm th? no ? t?o ra m?t ph?m vi

Lm theo cc b?c sau ? t?o ra m?t ph?m vi:
  1. Lm n?i b?t cc d? li?u.
  2. T? thanh tr?nh n, nh?p vo Chn, v sau nh?p vo Tn.
  3. Nh?p vo Xc ?nh, v sau nh?p vo Ph?m vi tn.
Lu y: Cc ? c?p ?n h?p s? chuy?n sang cc ph?m vi c?a b?n ?c t sng. i?u ny nn pht tri?n v co l?i khi d? li?u ?c chn v xa.

Truy xu?t d? li?u c?a b?n, s? d?ng tn ph?m vi b?n v?a t?o cho tn b?ng c?a b?n tuyn b? ch?n.

Excel b?c

  1. T?o Excel file, ki?m tra.XLS, v?i d? li?u sau trong sheet1:
       excel File : test.xls with the following entries:
            male  female    children   teens
             11    cc       78           ee
             22    xx       33           ff
             45    uu       56           oo
  2. T?o ?c ?t tn theo ph?m vi, myRange1 v myRange2, trong cc t?m c ch?a d? li?u thch h?p.
          named range : myRange1
          male female children teens
          named range  : myRange2
          11     cc   78   ee
          22     xx   33   ff
          45     uu   56   oo

Visual Basic Steps

  1. T?o ra m?t tiu chu?n EXE d? n m?i ?c g?i l "dao_excel."
  2. T? cc D an tr?nh n, nh?p vo Tham khao, v sau ch?n cc Th vi?n Microsoft DAO 3.5 h?p ki?m.
  3. ?t m?t CommandButton v? h?nh th?c.
  4. Dn o?n m? sau trong c?a s? m? m?u:
          private Sub Command_click1
          im dbtmp As DAO.Database
          im tblObj As DAO.TableDef
          im rs As DAO.Recordset
          et dbtmp = OpenDatabase_
               ("<complete path>\test.xls", False, True, "Excel 8.0;")
          Set rs = dbtmp.OpenRecordset("select * from `myRange2`")
          While Not rs.EOF
              For x = 0 To rs.Fields.Count - 1
                  Debug.Print rs.Fields(x).Value
          End Sub
          Note the reverse apostrophe "`" while specifying the range
Cc k?t qu? sau l nh mong ?i:


H?y tham kh?o ti li?u h?ng d?n ? lm th? no ? k?t n?i v?i Excel qua DAO. M?t ti li?u tham kh?o t?t s? l s?p t?i ADO-> Excel tham kh?o.

Thu?c tnh

ID c?a bi: 190195 - L?n xem xt sau cng: 20 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
T? kha:
kbdatabase kbhowto kbiisam kbmt KB190195 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:190195

Cung cp Phan hi


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com