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

[µo°Ý] ¿z¿ï°ÝÃD

[µo°Ý] ¿z¿ï°ÝÃD

½Ð±Ð¦U¦ì¥ý¶i2­Ó°ÝÃD
1.·í°õ¦æ¦¹µ{¦¡·|µo¥Í"°õ¦æ¶¥¬q¿ù»~'3704':·íª«¥óÃö³¬®É,¤£¤¹³\¾Þ§@",½Ð°Ý­n¦p¦ó­×¥¿
2.¨Ï¥ÎBlade(¼Æ­È)°µ¿z¿ï,¥i¿z¿ï¥X·Q­nªº¸ê®Æ,¦ý§ï¥Îentrydate(¤é´Á)¿z¿ï,µ{¦¡§ï¬°~FROM CFData where entrydate>2012/12/1,«oµLªk¿z¿ï¥X·Q­nªº¸ê®Æ
    ½Ð°Ý¬O§_­n¥t¥~«Å§i°Ñ¼Æ±ø¥ó

Sub aa()
   Dim cnn As New ADODB.Connection
   Dim rst As New ADODB.Recordset
    cnn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & ThisWorkbook.Path & "/Motion.mdb"   
    Sql = "SELECT entrydate,blade INTO [Excel 8.0;DATABASE=c:\test1.XLS].[main] FROM CFData where blade =1"         
    [a2].CopyFromRecordset cnn.Execute(Sql)    -->·|µo¥Í°õ¦æ¶¥¬q¿ù»~'3704':·íª«¥óÃö³¬®É,¤£¤¹³\¾Þ§@    cnn.Close
    cnn.Close
    Set cnn = Nothing
End Sub
¨Ï¥ÎBlade=1¥i±NBlade¬°1ªº¸ê®Æ¿z¿ï¥X¨Ó

¨Ï¥ÎentryDate>2012/12/1,µLªk¿z¿ï2012/12/1¥H«áªº¸ê®Æ

¦^´_ 1# jcchiang
1.  Sql = "SELECT entrydate,blade INTO [Excel 8.0;DATABASE=c:\test1.XLS].[main] FROM CFData where blade =1"
      §Ú¤£¤Ó²M·¡³oºØ¤£¶}ÀÉ´N¯à¦s¨úªº»yªk , ©Î¿ù¦b­þ(ÁöµM¬Ý°_¨Ó®¼¦n¥Îªº)
      ¦ý©³¤U¬O¥t¤@ºØ§@ªk , ¤]³\¯àÀ°¨ì§A
  1. Sub aa()
  2.     Dim sSaveFile As String
  3.     Dim cnn As New ADODB.Connection
  4.     Dim sql As String   

  5.     sSaveFile = "c:\test1.xlsx"   
  6.     cnn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & ThisWorkbook.Path & "/Motion.mdb"

  7.     With Workbooks.Add
  8.         With Sheets(1)
  9.             .Name = "main"  '¤u§@ªí¦WºÙ
  10.             sql = "SELECT entrydate,blade FROM CFData where blade =1"
  11.             .[a2].CopyFromRecordset cnn.Execute(sql)    '½Æ»s¨ìA2Àx¦s®æ
  12.         End With
  13.         .SaveAs sSaveFile
  14.         .Close
  15.     End With
  16.     cnn.Close
  17.     Set cnn = Nothing
  18. End Sub
½Æ»s¥N½X
2.  §ï where entrydate>#2012/12/1# ¬Ý¬Ý

TOP

1.¨Ï¥Î¥ý¶iªº§@ªk¥i¸Ñ¨M"·íª«¥óÃö³¬®É,¤£¤¹³\¾Þ§@"ªº°ÝÃD
¦ýExeclÀɮפº¦U¸ê®Æªº¼ÐÃD¨S¦³³Q½Æ»s¥X¨Ó,¬O§_¦³¸Ñ¨M¿ìªk
blade¿z¿ï1.jpg

2.¤é´Á«e«á¥[¤J#¥i¥H§ì¨ì¸ê®Æ
¥t¥~½Ð±Ð­Ó°ÝÃD,¦pªG¤é´Á­n¨Ï¥ÎInputBox¿é¤J
Dim myDate
  Do Until IsDate(myDate)
   myDate = Trim(InputBox("½Ð¿é¤J¬d¸ß°_©l¤é´Á", "¤é´Á", "YYYY/MM/DD"))
  Loop

where entrydate>myDate -->µLªk°õ¦æ,½Ð°Ý»yªk­n¦p¦ó­×¥¿

TOP

¦^´_ 3# jcchiang
  1. Sub aa()
  2.     Dim sSaveFile As String
  3.     Dim cnn As New ADODB.Connection
  4.     Dim rst As New ADODB.Recordset
  5.     Dim sql As String
  6.     Dim i As Long
  7.     Dim myDate
  8.       
  9.     Do Until IsDate(myDate)
  10.      myDate = Trim(InputBox("½Ð¿é¤J¬d¸ß°_©l¤é´Á", "¤é´Á", "YYYY/MM/DD"))
  11.     Loop
  12.    
  13.     sSaveFile = "c:\test1.xlsx"
  14.     cnn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & ThisWorkbook.Path & "/Motion.mdb"
  15.     With Workbooks.Add
  16.         With Sheets(1)
  17.             .Name = "main"  '¤u§@ªí¦WºÙ
  18.             sql = "SELECT entrydate,blade FROM CFData where entrydate>" & CLng(CDate(myDate))
  19.             Set rst = cnn.Execute(sql)
  20.             For i = 1 To rst.Fields.Count
  21.                 .Cells(1, i).Value = rst.Fields.Item(i - 1).Name
  22.             Next i
  23.             .[a2].CopyFromRecordset rst   '½Æ»s¨ìA2Àx¦s®æ
  24.         End With
  25.         .SaveAs sSaveFile
  26.         .Close
  27.     End With
  28.     cnn.Close
  29.     Set rst = Nothing
  30.     Set cnn = Nothing
  31. End Sub
½Æ»s¥N½X

TOP

ÁÂÁ«ü¾É,¥Ø«e°ÝÃD¤w¸Ñ¨M

TOP

        ÀR«ä¦Û¦b : ·O´d¨S¦³¼Ä¤H¡A´¼¼z¤£°_·Ð´o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD