nvthanghcm > 07-10-14, 05:43 PM
vulhu06 > 09-10-14, 09:48 AM
(07-10-14, 05:43 PM)nvthanghcm Đã viết: A/c giup gium cau lenh sai nhu the nao minh ko chay duoc.
minh muon tim kiem truc tiep tren form, khi hoso trung thi load hoso do ra form.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim rs As Recordset
Dim thongbao As Boolean
Set rs = CurrentDb.OpenRecordset("bang_th", dbOpenTable)' table co ten la bang_th
rs.MoveFirst
thongbao = False
Do While Not rs.EOF
If rs.Fields("id") = idhoso.Value Then ' trong table co file id, tren form co textbox: idhoso
thongbao = True
Exit Do
End If
rs.MoveNext
Loop
If thongbao = False Then
MsgBox "ko tom thay "
Else
Me.Bookmark = rs.Bookmark
MTNQ > 22-10-14, 01:38 AM
(07-10-14, 05:43 PM)nvthanghcm Đã viết: A/c giup gium cau lenh sai nhu the nao minh ko chay duoc.
minh muon tim kiem truc tiep tren form, khi hoso trung thi load hoso do ra form.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim rs As Recordset
Dim thongbao As Boolean
Set rs = CurrentDb.OpenRecordset("bang_th", dbOpenTable)' table co ten la bang_th
rs.MoveFirst
thongbao = False
Do While Not rs.EOF
If rs.Fields("id") = idhoso.Value Then ' trong table co file id, tren form co textbox: idhoso
thongbao = True
Exit Do
End If
rs.MoveNext
Loop
If thongbao = False Then
MsgBox "ko tom thay "
Else
Me.Bookmark = rs.Bookmark
Set rs = CurrentDb.OpenRecordset("bang_th", dbOpenTable)
Private Sub Idhoso_AfterUpdate()
With Me
.txtID.SetFocus 'txtID là text box trên from và có nguồn là trường [id]
DoCmd.FindRecord .Idhoso
If .txtID.Value <> .Idhoso.Value Then
MsgBox "Khong tim thay du lieu yeu cau"
.txtID.SetFocus
End If
End With
End Sub
Sub FindRecord()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[id] = " & Nz(Me.Idhoso, "")
If rs.NoMatch Then
MsgBox "Khong tim thay: " & Me.Idhoso
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End Sub