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

[µo°Ý] Excel³sµ²¦³¥[±KAccess¸ê®Æ®w»yªk°£¿ù

[µo°Ý] Excel³sµ²¦³¥[±KAccess¸ê®Æ®w»yªk°£¿ù

HI ¦U¦ì«e½ú°ª¤â
¥Ø«e¦bexcel¤¤¼g¤F¥¨¶°³sµ²access¸ê®Æ®w
¦b¥¼¥[±K¤§«e¬O¥i¶¶§Q°õ¦æªº
¦ý¤@§âaccess¥[±K«á
access¥X²{
run excelµ{¦¡´N·|¥X²{¤£¬O¦³®Ä±K½Xªº¿ù»~¥N½X
ºô¤W¬d¹L«Ü¦h¸ê°T¤F¦ý³£µLªk¸Ñ¨M0.0

·Q½Ð°Ý¸Ó¦p¦ó­×§ïaccess¥[±K»yªk?
  1. Private cnnDB As ADODB.Connection
  2. Private recSet As ADODB.Recordset
  3. Private cnnStr As String
  4. Sub Main()

  5. Dim tblName As String

  6. Set cnnDB = New ADODB.Connection
  7. Set recSet = New ADODB.Recordset
  8. '¦¹¦æµL¥[±K¡A¥i¹B¦æ
  9. '  cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & ThisWorkbook.Path & "\Database3.accdb;" & "Jet OLEDB:Database"
  10. '¦¹¦æ¬Oaccess¦³¥[±K·|¥X²{¿ù»~
  11.   cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & ThisWorkbook.Path & "\Database3.accdb;" & "Jet OLEDB:Database Password=123"
  12.   
  13.     tblName = "User_List"
  14.     cnnDB.Open cnnStr
  15.    
  16.     With recSet
  17.         .CursorLocation = adUseClient
  18.         .Source = "SELECT * FROM " & tblName & " where [Number]= '" & Worksheets("main").Range("C5") & "';"
  19.         .ActiveConnection = cnnDB
  20.         .Open
  21.     End With
  22.    
  23.     If recSet.RecordCount > 0 Then
  24.         MsgBox ("¨Ï¥Î¤H­û¤wµn¤J" & vbCrLf & _
  25.                             "Welcome, User.")
  26.         recSet.Close
  27.         cnnDB.Close
  28.         Set recSet = Nothing
  29.         Set cnnDB = Nothing


  30.     Else
  31.         MsgBox ("¬dµL¨Ï¥Î¤H­û"), vbExclamation

  32.     End If





  33. End Sub
½Æ»s¥N½X
access¥[±K.zip (415.17 KB)

¦^´_ 1# Changbanana

±z¦n,
      ½Ð°Ñ¦Ò©³¤U³sµ².
http://discuz.bestdaylong.com/thread-38249-1-1.html
Excel¦p¦ó¶}±Ò¦³±K½X«OÅ@ªºAccessÀÉ®×accdbÀÉ®×
°Ñ¦Ò¸ê®Æ¡G
http://bestdaylong.com

TOP

¦^´_ 2# imingho

    ÁÂÁ±z
    ¨Ï¥Î³o¤èªk¦³¦¨¥\¸Ñ¨M°ÝÃD¤F!!

TOP

        ÀR«ä¦Û¦b : ºw¤ô¦¨ªe¡C²É¦Ì¦¨ÅÚ¡A¤Å»´¤vÆF¡A¤Å¥Hµ½¤p¦Ó¤£¬°¡C
ªð¦^¦Cªí ¤W¤@¥DÃD