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