- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 3# dechiuan999
§Ú¨S¦³¨Ï¥Î¹L¸ê®Æ®w³nÅé
¸ê®Æ®wªº¨Ï¥Î¤j¦P¤p²§.ªþÀɬOºô¸ô¤W¤U¸üªº¥i°Ñ¦Ò¤@¤U.
Ex.rar (210.96 KB)
- Option Explicit
- Sub Ex()
- '¤Þ¥Î Microsoft DAO 3.0 Object Libiary
- Dim myData As String, myTable As String, SQL As String
- Dim myDb As DAO.DataBase
- Dim myRs As DAO.Recordset
- Dim i As Integer
- Dim code, dateSold
- ActiveSheet.Cells.Clear '²M°£¤u§@ªíªº¥þ³¡¸ê®Æ
- myData = "D:\TEMP\EX6.mdb"
- Set myDb = OpenDatabase(myData)
- code = 5 '¸ê®ÆªíªºÄæ¦ì FieldType ¬OdbSingle' 6
- dateSold = "'¦n³Ü¨F¤h'" '¸ê®ÆªíªºÄæ¦ì FieldType ¬O dbText '10
- SQL = "UPDATE tb²£«~2A SET ³æ¦ì¼Æ¶q=88 WHERE ((²£«~½s¸¹)=" & code & ") AND ((²£«~¦WºÙ)=" & dateSold & ") "
- myDb.Execute (SQL) '
- SQL = "select * from tb²£«~2A WHERE ²£«~½s¸¹<=" & code
- Set myRs = myDb.OpenRecordset(SQL)
- If myRs.RecordCount > 0 Then
- For i = 1 To myRs.Fields.Count '½Æ»sÄæ¦ì¦W
- Cells(1, i) = myRs.Fields(i - 1).Name
- Next i
- '³]¸mÄæ¦ì¦W¦rÅ鬰¥[²Ê¨Ã©~¤¤¹ï»ô
- With Range(Cells(1, 1), Cells(1, myRs.Fields.Count))
- .Font.Bold = True
- .HorizontalAlignment = xlCenter
- End With
- Range("A2").CopyFromRecordset myRs '½Æ»s¥þ³¡¸ê®Æ
- End If
- 'Ãö³¬°O¿ý¶°¤Î¸ê®Æ®w³s±µ , ¨ÃÄÀ©ñÅܼÆ
- myRs.Close
- myDb.Close
- Set myRs = Nothing
- Set myDb = Nothing
- End Sub
½Æ»s¥N½X |
|