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

[µo°Ý] Excel¤u§@ªí³æ»PAccess¸ê®Æ®wªºVBA¤¬°Ê°ÝÃD

¦^´_ 34# JEAN
½Ð°Ý©p¬O­n°õ¦æ MDF ¸ê®Æ®w¡B§í©Î¬O ACCDB ¸ê®Æ®w¡H
¦]³o¨âºØ¸ê®Æ®wªºÅX°Êµ{¦¡¬O¤£¦Pªº¡C
For Access MDF (2003)¡G
  1.     .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & _
  2.                           ThisWorkbook.Path & Application.PathSeparator & "¾÷²¼°O¿ý©ú²Óªí.mdb" & ";"
½Æ»s¥N½X
For Access Accdb (2007¡B2010)¡G
  1.     '  For Microsoft.ACE.OLEDB.12.0,you need Microsoft Office 12.0 Access Database Engine to be installed.
  2.     .ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;" & "Data Source=" & _
  3.                          ThisWorkbook.Path & Application.PathSeparator & "¾÷²¼°O¿ý©ú²ÓªíÀÉ®×.accdb" & ";"
½Æ»s¥N½X
·í©p­n¨Ï¥Î Accdb ¸ê®Æ®w®É¡A©pµ{¦¡½XªºÅX°Êµ{¦¡«K­n±Ò°Ê For Access Accdb¡B¤Ï¤§¥çµM¡C

TOP

¦^´_ 33# c_c_lai


    ±z¦n:   §Ú¦³§Aªº¤èªk...·|¥X²{³o­Ó¿ù»~~~~
      

    ±z¦n:   §Ú§âÀɮפG­Ó©ñ¦b¤@°_¤W¶Çµ¹§A~~½ÐÀ°§Ú¬Ý¬Ý..ÁÂÁ±z
      2014¦~¾÷²¼°O¿ý¤G­ÓÀɮפ@°_.rar (141.5 KB)

TOP

¦^´_ 26# JEAN
¶¶§ÇÀ³¥ý±q ThisWorkbook ªºµ{¦¡½X¬Ý°_¡AµM«á¦A¤À§O¥hÁA¸Ñ
Sheets("¾÷²¼§@·~")¡B¥H¤Î Sheets("¾÷²¼µn¿ý") ¤ºªºµ{¦¡½X¡A
©pªº­«ÂI¥i¥H¥ý©ñ¦b ("¾÷²¼µn¿ý") ¤W¡C ²z¸Ñ«á¦A¦æ¥hÅé·|
("¾÷²¼§@·~")¡B¦p¦¹©pªº¶i®i¤~·|¶¶§Q¡C³Ì«á¤~¥hÁA¸Ñ "¼Ò²Õ"
¸Ì¦p¦ó³B¸Ì ComboBox ¤º¦p¦óÀ³¥Î·Æ¹«ºu¶bªº¹B§@(Hook)¡B
¥H¤Î¦p¦óÄÀ©ñ (UnHook)¡C¦Ü©ó¸ê®Æ®wµ²ºc«O«ù¤£ÅÜ(Mdf¡BAccdb)¡C
³Ì«á¡B¯¬©p¤@¦|­·¶¶¡I
2014¦~¾÷²¼°O¿ý.rar (123.68 KB)

TOP

¦^´_ 26# JEAN
³o¸Ì¡A§Ú¤w¦A¥[¤J¤@­Ó·sªº¤u§@ªí³æ Sheets("¾÷²¼µn¿ý")¡A¦b¦¹ªí³æ¤º
"¾÷²¼µn¿ý" ¥u³æ¯Â³B²z¸ê®Æ·s¼W¡B§ó·s¡B§R°£¡B­«¸mµ¥¿é¤J§@·~¡A¬ÛÃöªº
¸ê®ÆÀx¦s§@·~«h¥þ¥æ¥Ñ Access ¾÷²¼°O¿ý©ú²Óªí.mdb ¸ê®Æ®w¦s¨ú¬ö¿ý¡C
¦Ü©ó­ì Sheets("data") ªº¬ö¿ý«h¨ÌµM«O¯dµ¹¤u§@ªí³æ "¾÷²¼§@·~"¡A
§@¬°Âù¦VÀx¦s½d¨Ò¤§¥Î¡C¤]´N¬O»¡¡B¤u§@ªí³æ "¾÷²¼µn¿ý" ©Î³\´N¬O
©pªº»Ý¨D (µ{¦¡½X¦b¨ä"¾÷²¼µn¿ý"¥»¨­¤u§@ªí³æ¤º)¡A©p¥i¥H±N¥¦»P
"¾÷²¼§@·~"¤º¤§µ{¦¡½X¬Û¤¬¤ñ¸û¡A«K¥i»â·|¨âªÌ¤§¶¡³B²z¤Wªº®t²§¡A
¶i¦Ó¥i§@¬°©p­Ó¤H»â°ì¤W¤§±´°Q¤Î¬ã¨s¡C

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-12-27 18:03 ½s¿è

¦^´_ 30# JEAN
³o­Ó¬O§R°£¸ê®Æ¿ýªºµ{¦¡½X¡A
¨ä¤º®e¬O­º¥ý·|§R°£ Sheets("data") ¤º¹ïÀ³ªº³Q§R°£¸ê®Æ¡A
±µµÛ¡B¦^ÀY¤SÄ~Äò¥h§R°£Àx¦s¦b Access ªº¹ïÀ³ªº¸ê®Æ¡A¥H«O«ù¨âªÌ¸ê®Æ¦P¨B¤§¬G¡C
­º¥ý¡B©pÀ°§ÚÀˬd¤@¶µ°Ê§@¡G
A¡B  ¥ý¤Ä¿ï  "SQL Data"¡CµM«á¦b "¦W¦r" ÄæÀH«K¿é¤J¤@¦W¦r¡B¦p¡G LuLu¡C
B¡B  ¿é§¹ LuLu «á¡AÂI¿ï "¿é¤J½T©w" «ö¶s¡A±µµÛÂI¿ï "ñÃÒ¤º®e1"¡B©ÎªÌ¬O
         "ñÃÒ¤º®e2"¡AµM«áÁ@Á@¸Ì­±¦³¨S¦³ "ñÃҿﶵ"¡A¦pªGµª®×¬O "Yes"¡A
        ¨º«K­n®¥³ß©p¤w§ä¨ì(³sµ²¨ì) Access ¸ê®Æ®w¤F¡C
C¡B  ³Ì«á©p¤~§i¶D§Ú¡A©p¹ê»Ú·Q°µªº¬O¬Æ»ò¡H

TOP

¦^´_  c_c_lai


±z¦n:
ÁÂÁ±zªº¾÷²¼§@·~,½Ð°Ý§Ú¬O§_¥i¥H§ï¬°§â¦W¦r¥Î¿ï¶µ¤è¦¡¿é¤J.....µM«á¦Û°Ê±a¤J ...
JEAN µoªí©ó 2013-12-27 13:32


Private Sub DeleteData_Click()
    Dim nCode As Range, ret As Boolean
   
    With Sheets("data")
        Set nCode = .[B:B].Find(CallID.Text, , , 1)
        .Rows(Val(Mid(nCode.Address, 4))).EntireRow.Delete Shift:=xlUp
    End With
   
    ret = ExcelData.Value
    ExcelData.Value = False
   
    closeRS
    OpenDB
   
    strSQL = "DELETE FROM ¾÷²¼°O¿ý WHERE ¦W¦r = '" & CallID.Text & "'"
    cmd.CommandText = strSQL
   
    cmd.ActiveConnection = cnn
    cmd.Execute
    cnn.Close
   
    Confirm.Enabled = True
    ExcelData.Value = ret
    ResetData_Click
End Sub


½Ð°Ý¬O§ï³oÃä¶Ü?

TOP

¦^´_ 28# c_c_lai


  ±z¦n:

§Úªº·N«ä¬O»¡:¦pªG¿ï¾ÜSQL DATA¤è¦¡ ¿é¤J¸ê®Æ....¥LªºÀx¦s©ú²ÓªíÀ³¸Ó¬O¦bACCESS§a....¥i¬O§Ú¶}±ÒACCESS©ú²Óªí,¥²¨S¦³§Ú¿é¤Jªº¸ê®Æ¡C

§Ú·|·Q¥Î¨ìACCESS¸ê®Æ®w¸Ì­±¬O¤è«K¬d¸ß,¦Ó¥B¥i¥H¤@ª½¼W¥[¦~«×...Ä´¦p©ú¦~¬O2014¦~¥Î§¹,§ÚÁÙ¥i¥H¦bACCESS©ú²Óªíª½±µ¦b¥[¤W2015¦~«×´N¥i¥H¤F¡C

³o¼Ë§Ú´N¤£¥Î¨C¦~·Q­n¦p¦ó¥h°µ,¦Ó¥B§Ú¥´ºâ¤µ¦~§âªí®æ·d©w¦n§â©Ò¦³ªº¯ÊÂI©MÀuÂI¾ã¦X¥X¨Ó¡C  ¥H«á¤]¥i¥H´£¨Ñ¨ä¥Lºô¤Í°µ¨Ï¥Î¡C  

¥t¥~¯uªº«Ü·PÁ c_c_lai À°§U¤~¯à§¹¦¨ªí®æ¡C

TOP

¦^´_ 26# JEAN
¤S¡B©p»¡¥Î³£¤£¦æ¡H
¦¹¸Ü«ç»¡¡H
©p¬O«üª½±µÂI¿ï "¾÷²¼°O¿ý©ú²Óªí.mdb" ³£µLªk¶i¤J¨ì Access ¶Ü¡H

TOP

¦^´_  c_c_lai


±z¦n:
ÁÂÁ±zªº¾÷²¼§@·~,½Ð°Ý§Ú¬O§_¥i¥H§ï¬°§â¦W¦r¥Î¿ï¶µ¤è¦¡¿é¤J.....µM«á¦Û°Ê±a¤J ...
JEAN µoªí©ó 2013-12-27 13:32

·íµM¥i¦æ¡A¥u­n¬O VBA »yªk¯à³B¸Ìªº¡A´X¥G³£¦³¹ê²{¤§¥i¯à¡C
¥t¥~§ÚºK¿ý¤F SQL ¤@µüªº¸ÑÄÀ¡G
µ²ºc¤Æ¬d¸ß»y¨¥¡]Structured Query Language¡AÁY¼g¬°SQL¡^¡A¤@ºØµ{¦¡»y¨¥¡A¥Î©ó¸ê®Æ®w¤¤ªº¼Ð·Ç¸ê®Æ¬d¸ß»y¨¥¡AIBM¤½¥q³Ì¦­¨Ï¥Î¦b¨ä¶}µoªº¸ê®Æ®w¨t²Î¤¤¡C1986¦~10¤ë¡A¬ü°ê°ê®a¼Ð·Ç¾Ç·|¡]ANSI¡^¹ïSQL¶i¦æ³W½d«á¡A¥H¦¹§@¬°ÃöÁp¦¡¸ê®Æ®wºÞ²z¨t²Îªº¼Ð·Ç»y¨¥¡]ANSI X3. 135-1986¡^¡A1987¦~±o¨ì°ê»Ú¼Ð·Ç²Õ´ªº¤ä´©¤U¦¨¬°°ê»Ú¼Ð·Ç¡C¤£¹L¦UºØ³q¦æªº¸ê®Æ®w¨t²Î¦b¨ä¹ê½î¹Lµ{¤¤³£¹ïSQL³W½d§@¤F¬Y¨Ç½s§ï©MÂX¥R¡C©Ò¥H¡A¹ê»Ú¤W¤£¦P¸ê®Æ®w¨t²Î¤§¶¡ªºSQL¤£¯à§¹¥þ¬Û¤¬³q¥Î¡C
¬Ý§¹¤F³o¬q»¡©ú¡A§AÀ³¸Ó«K¯à¤F¸Ñ¨ì SQL ¥¦§êºtªº¥u¬O¤@¯ëµ{¦¡»y¨¥»P¸ê®Æ®w¶¡ªº¤@­Ó¤¶­±»y¨¥¡C¨Ò¦p¡G
¥»µ{¦¡½X¸Ìªº¡G
  1.     If ExcelData.Value = True Then
  2.         '  strSQL = "Select Distinct [ñÃÒ¤º®e] From [ñÃÒ¶µ¥Ø$] Order by [ñÃÒ¤º®e]"
  3.         strSQL = "Select * From [ñÃÒ¶µ¥Ø$] Order by [ñÃÒ¤º®e]"
  4.     Else
  5.         '  strSQL = "Select Distinct ñÃÒ¤º®e From ñÃÒ¶µ¥Ø Order by ñÃÒ¤º®e"
  6.         strSQL = "Select * From ñÃÒ¶µ¥Ø Order by ñÃÒ¤º®e"
  7.     End If
  8.    
  9.     '  closeRS
  10.     OpenDB
  11.   
  12.     rs.Open strSQL, cnn, 1, 3     '  adOpenKeyset, adLockOptimistic
  13.     If rs.RecordCount > 0 Then
  14.        .
  15.        .
  16.     End If
  17.       .
½Æ»s¥N½X
µ¥»P¸ê®Æ®w¦s¨ú¦³Ãö»yªk¬ÒÄݤ§¡C

TOP

¦^´_ 25# c_c_lai


±z¦n:
ÁÂÁ±zªº¾÷²¼§@·~,½Ð°Ý§Ú¬O§_¥i¥H§ï¬°§â¦W¦r¥Î¿ï¶µ¤è¦¡¿é¤J.....µM«á¦Û°Ê±a¤J"³æ¦ì"³o­ÓÄæ¦ì¡C
´N¹³§Ú"¾÷²¼"¸Ì­±ªº¦W¦r....·|¦Û°Ê±a¤J"³æ¦ì"¡C

½Ð°ÝSQL¬Oµn¤J¨ìACCESSªº·N«ä¶Ü??  ¥i¬O§Ú¥Î³£¤£¦æ~~

TOP

        ÀR«ä¦Û¦b : Ãø¦æ¯à¦æ¡AÃø±Ë¯à±Ë¡AÃø¬°¯à¬°¡A¤~¯àª@µØ¦Û§Úªº¤H®æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD