cuongvan09 > 17-06-12, 11:42 AM
Option Compare Database
Public Function TimGBan(nNgay As Date, mMaso As String)
Dim StrSQL As String
Dim DB As DAO.Database
Dim rs As DAO.Recordset
Set DB = CurrentDb
StrSQL = "Select Top 1 DonGia From GIABAN Where Masp='" & mMaso
StrSQL = StrSQL & "' And format(Ngay,'yyyy/mm/dd')<='" & Format(nNgay, "yyyy/mm/dd") & "' order by Ngay desc"
Set rs = DB.OpenRecordset(StrSQL)
If Not rs.EOF Then
TimGBan = rs!DonGia
Else
TimGBan = Null
End If
End Function
Noname > 17-06-12, 12:02 PM
msgbox "Giá bán của A là: " & TimGBan(#05/20/2012#,'A')