ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA ³sµ² Access ªº°ÝÃD½Ð±Ð

[µo°Ý] VBA ³sµ² Access ªº°ÝÃD½Ð±Ð

¦]¬°¯S®í¤u§@»Ý¨D¤@©w­n¥ÎExcel »PAccess§@³sµ²¡A©Ò¥H§Ú¨Ì·Ó½d¨Ò¼g¤F¤@­Ó´ú¸Õµ{§Ç¡A
¥¦·|§â¸ê®Æ¶K¦b Sheet ¤ºªºA2¡A§Ú­n¦p¦ó§âRUN¥X¨Óªº¤§®Æ©ñ¶iÅܼƤº?
§Ú³Ì¥D­nªº¥Øªº¬O ¥ÎEXCEL2007 ¶}Access2003ªº¸ê®Æ®w,±q¤¤¿z¿ï®×¥óª¬ºA='2'
ªºP1Á`®É¶¡§@¥[Á`
§Æ±æ¦³¤H¯àÀ°§Ú
  1. Sub aa()
  2. Dim cnn As New ADODB.Connection
  3. Dim rst As New ADODB.Recordset

  4. cnn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & ThisWorkbook.Path & "\CCBO.MDB"

  5. sq1 = "select AVG(P1Á`®É¶¡) from CCBO where ®×¥óª¬ºA='2'"

  6. [a2].CopyFromRecordset cnn.Execute(sql)

  7. cnn.Close
  8. Set cnn = Nothing
  9. End Sub
½Æ»s¥N½X

¦^´_ 1# uf023630
¬Ý¤£¥X¿ù»~¦b­þ
´£¿ô¤@¤U
¸ê®Æ®wªº¦W¦r¥sCCBO
§A­n¬d¸ßªº¸ê®Æªí¤]¥sCCBO¶Ü?
Alex

TOP

RUN °_¨Ó¬O¨S°ÝÃD
¦ý¬O [a2].CopyFromRecordset cnn.Execute(sql) ·|§â¸ê®Æ¶K¨ìsheet¥h¡A¦ý¬O§Ú­nªº¬O
±NRUN ¥X¨Óªº¸ê®Æ©ñ¨ìÅܼƥh

TOP

RUN °_¨Ó¬O¨S°ÝÃD
¦ý¬O [a2].CopyFromRecordset cnn.Execute(sql) ·|§â¸ê®Æ¶K¨ìsheet¥h¡A¦ý¬O§Ú­nªº¬O
±N ...
uf023630 µoªí©ó 2012-5-17 17:48


¥i¥H°Ñ¦Ò¤@¤U³o¸Ì½d¨Ò¤G
http://kimbalko-chi.blogspot.com/2010/06/how-toexcel-vba-sql.html

§âsqlÂର
    sq1 = "select AVG(P1Á`®É¶¡) as P1_avg_time from CCBO where ®×¥óª¬ºA='2'"

¤£¥Î³o­Ó
[a2].CopyFromRecordset cnn.Execute(sql)
Âର¥Îrecord set±µ¤W
Set rst = cnn.Execute(strQuery)
³Ì«á§â¼Æ­È©ñ¨ìÅܼÆ
ÅÜ¼Æ = rst.Fields("P1_avg_time").Value
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

        ÀR«ä¦Û¦b : ¤H­nª¾ºÖ¡B±¤ºÖ¡B¦A³yºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD