G
gr
Hi, I have frmProject which has a subform named
frmDocumentsDelivered. frmProject Record Source is a query
which is filtered in the PrjName field, in the same way
frmDocumentsDelivered Record Source is a query filtered in
the PrjName field. (Criteria: [Forms]![frmPrjName].[Form]!
[cboPrjName])
I want to open frmProject filtered by an specific project
(already filtered from the query) and then filter
frmDocumentsDelivered to mach a keyword given by the user.
I don't know how to do this, Every time I get frmProject
opened with no recrods, just empty even when there's a
match with the keyword.
My code looks like this:
Private Sub cmdSearch_Click()
On Error GoTo Search_err
If IsNull(Me.cboPrjName) Then
MsgBox "Please choose a Project from the list!",
vbCritical, "Warning"
Exit Sub
End If
Dim strKey() As String
Dim strSQL As String
Dim intNo As Integer
Dim intUpper As Integer
If IsNull(Me.txtKeyword) Then
DoCmd.OpenForm "frmProject", acNormal
Exit Sub
End If
strKey = Split(Me.txtKeyword, " ", -1)
intUpper = UBound(strKey)
Do While intNo <= intUpper
strSQL = "Forms!frmProject!frmDeliveredDocuments!
DocName Like " _
& """" & "*" & strKey(intNo) & "*" & """"
& " OR " _
& "Forms!frmProject!frmDeliveredDocuments!
DrawingNo Like " _
& """" & "*" & strKey(intNo) & "*" & """"
& " OR " & strSQL
intNo = intNo + 1
Loop
strSQL = Left(strSQL, Len(strSQL) - 3)
DoCmd.OpenForm "frmProject", acNormal, , strSQL
Salir_Sub:
Exit Sub
Search_err:
MsgBox "Error " & Err.Number & ": " &
Err.Description
Resume Salir_Sub
End Sub
thx.
frmDocumentsDelivered. frmProject Record Source is a query
which is filtered in the PrjName field, in the same way
frmDocumentsDelivered Record Source is a query filtered in
the PrjName field. (Criteria: [Forms]![frmPrjName].[Form]!
[cboPrjName])
I want to open frmProject filtered by an specific project
(already filtered from the query) and then filter
frmDocumentsDelivered to mach a keyword given by the user.
I don't know how to do this, Every time I get frmProject
opened with no recrods, just empty even when there's a
match with the keyword.
My code looks like this:
Private Sub cmdSearch_Click()
On Error GoTo Search_err
If IsNull(Me.cboPrjName) Then
MsgBox "Please choose a Project from the list!",
vbCritical, "Warning"
Exit Sub
End If
Dim strKey() As String
Dim strSQL As String
Dim intNo As Integer
Dim intUpper As Integer
If IsNull(Me.txtKeyword) Then
DoCmd.OpenForm "frmProject", acNormal
Exit Sub
End If
strKey = Split(Me.txtKeyword, " ", -1)
intUpper = UBound(strKey)
Do While intNo <= intUpper
strSQL = "Forms!frmProject!frmDeliveredDocuments!
DocName Like " _
& """" & "*" & strKey(intNo) & "*" & """"
& " OR " _
& "Forms!frmProject!frmDeliveredDocuments!
DrawingNo Like " _
& """" & "*" & strKey(intNo) & "*" & """"
& " OR " & strSQL
intNo = intNo + 1
Loop
strSQL = Left(strSQL, Len(strSQL) - 3)
DoCmd.OpenForm "frmProject", acNormal, , strSQL
Salir_Sub:
Exit Sub
Search_err:
MsgBox "Error " & Err.Number & ": " &
Err.Description
Resume Salir_Sub
End Sub
thx.