Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter report from subform , code error

Status
Not open for further replies.

Aliffi

MIS
Jan 9, 2005
51
0
0
BE
Dears,
I have a database back SQL Sy2k front ADP , I have a form and it has a sub form , now i want to filter my form with a combo box and a button and the button is going to alter a report with the filtered criteria and open the report restricted with that filter,.

as it is a sub form , i could not find a fine path to define the sub form for the module. can any one help
if i open the subform individually it works fine but it does not work inside the main form

here is the code

'-------------------------------------------------------

Dim strWhere As String
Dim frm As Form

'-----------------------------------------
'The form (define in the below line "Tasksubform" is a subfom)
'------------------------------------------
Set frm = Forms!Tasksubform.Form


If Nz(frm!tm, "") <> "" Then
strWhere = "[taskm]='" & frm!tm & "'"
End If
If Nz(frm!txtyn, "") <> "" Then
strWhere = "pending='" & frm!txtyn & "'"
End If
'--------------------------------------------------------

If Nz(frm!tm, "") <> "" Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND taskm='" & frm!tm & "'"
Else
strWhere = "taskm='" & frm!tm & "'"
End If
End If

'======================================================'
If Nz(frm!txtyn, "") <> "" Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND pending='" & frm!txtyn & "'"
Else
strWhere = "pending='" & frm!txtyn & "'"
End If
End If
'======================================================'
If Len(strWhere) > 0 Then
DoCmd.ApplyFilter , strWhere



DoCmd.OpenReport "tasks_all", acViewPreview, , Form.Filter

Else
MsgBox "Please Enter a Criteria in the boxes", vbExclamation, "Alert"

End If

End Sub
'----------------------------------------------------------

any help is appreciated
thanks
 
Check out thread958-1260216 I think this might answer your question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top