duhslienxo
Thành viên mới

- Tham gia
- 6/1/14
- Bài viết
- 2
- Được thích
- 0
Tình hình là em có cái form như thế.em không biết sai đoạn code vba ở đâu mà k bấm được tất cả các nút nào hết trên form.ae giúp tôi.xin cảm ơn !!!
Mã:
Private Sub cmdClose_Click()
DoCmd.Close
End Sub
Private Sub cmdSearch_Click()
On erorr GoTo errr
Me.infoTBL_subform.Form.RecordSource = "SELECT * FROM infoTBL " & BuildFilter
Me.infoTBL_subform.Requery
errr:
MsgBox errr.Description
End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim tmp As String
tmp = """"
varWhere = Null
If Me.txtTenthuoc > "" Then
varWhere = varWhere & "[Tenthuoc] like " & Me.txtTenthuoc & " AND "
End If
If Me.txtmasothuoc > "" Then
varWhere = varWhere & "[Masothuoc] like " & tmp & Me.txtmasothuoc & tmp & " AND "
End If
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE" & varWhere
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
End Function
Private Sub Command11_Click()
Me.infoTBL_subform.Form.RecordSource = "SELECT * FROM infoTBL "
txtTenthuoc = ""
txtmasothuoc = ""
End Sub
Private Sub Form_Current()
cmdClear_Click
End Sub