Don't know how to filter

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.
 
G

gr

Sorry, I figured out, I put the sub forms filter on the on
load event.

if NotIsNull (strkeyword) Then
dim strSQL as string
strSQL = " bla bla bla"
Me.Filter = strSQL
Me.FilterOn = True
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top