canhcfc > 08-11-14, 05:09 PM
Private sub demRecord()
dim db as dao.database
dim rs as dao.recordset
Set db = currentdb
set rs = db.openrecordset("VATTU")
Text0.value = rs.recordcount
End sub
MTNQ > 09-11-14, 12:28 PM
Text0.value = DCount("*", "VATTU")
MTNQ > 09-11-14, 12:51 PM
Private Sub demRecord()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT Count(*) as RCnt FROM "VATTU"", dbOpenSnapshot)
Text0.Value = rs!RCnt
End Sub
canhcfc > 09-11-14, 01:26 PM
(09-11-14, 12:51 PM)MatTroiNguQuen Đã viết: Nếu vẫn thích DAO thì code như sau:
Mã:Private Sub demRecord()
Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT Count(*) as RCnt FROM "VATTU"", dbOpenSnapshot)
Text0.Value = rs!RCnt
End Sub
Còn đưa các table đã split vào trở lại thì đơn giản là import nó trở lại thui (Trên menu chọn External Data > Access > ... )
db.openrecordset("VATTU")
MTNQ > 09-11-14, 02:14 PM
Private sub demRecord()
dim db as dao.database
dim rs as dao.recordset
Set db = currentdb
set rs = db.openrecordset("VATTU")
rs.MoveLast
Text0.value = rs.recordcount
End sub
MTNQ > 09-11-14, 02:36 PM
Trích dẫn:Note
Using the MoveLast method to populate a newly opened Recordset negatively impacts performance. Unless it is necessary to have an accurate RecordCount as soon as you open a Recordset, it's better to wait until you populate the Recordset with other portions of code before checking the RecordCount property.
canhcfc > 10-11-14, 01:00 PM
db = opendatabase(Me.Application.Currentproject.path & "\DATA_QLVT.accdb")