L
Lisa M. Fida
Windows XP, Access 2003
I have an unbound main form with a bound (to an SQL statement) subform. The
subform's SQL statement has a field called 'Posted' which uses the value of
an unbound option group on the main form to select the appropriate records
(1=No, 2=Yes). The OptionGroup_AfterUpdate event requeries the subform and
works perfectly. The problem occurs when I apply a filter to the form and
then unapply the filter. When I apply the filter (filtering on a field
called 'Vendor') it still gives the desired results; i.e. I can click on the
option group and get the Posted or Unposted records for the selected Vendor.
When I remove the filter the subform displays all the records for Posted (if
that was originally selected when the filter was applied) or Unposted (if
that was originally selected). But if I click the other option nothing
happens. Very frustrating. Here is my code:
My subform's SQL statement:
SELECT APHeader.APHdrRID, APHeader.Vendor, APHeader.Name, APHeader.Invoice,
APHeader.InvoiceDescription, Choose(APHeader!InvoiceType,"Invoice","Credit
Memo") AS InvoiceType, APHeader.InvoiceDate, APHeader.DueDate,
APHeader.DiscountDate, APHeader.InvoiceAmt, APHeader.Posted
FROM APHeader
WHERE (((APHeader.Posted)=CStr([Forms]![APInvoiceMain]![optPostingStatus])));
My option group code:
Private Sub optPostingStatus_AfterUpdate()
On Error GoTo ErroptPostingStatus_AfterUpdate
Dim frm As Form
Set frm = Forms!APInvoiceMain!subfrmAPInvoiceMainSub.Form
frm.Requery
ExitoptPostingStatus_AfterUpdate:
Exit Sub
ErroptPostingStatus_AfterUpdate:
MsgBox Err.Description
Resume ExitoptPostingStatus_AfterUpdate
End Sub
My filter code:
Private Sub tglApplyFilter_Click()
On Error GoTo ErrtglApplyFilter_Click
Dim frm As Form
Dim strFilterField As String
Dim strFilterValue As String
Dim strFormFilter As String
Set frm = Forms!APInvoiceMain!subfrmAPInvoiceMainSub.Form
If Me!tglApplyFilter.Value Then
strFilterField = Me!cboFilterField
strFilterValue = Me!cboFilterValue
strFormFilter = "[" & strFilterField & "] = '" & strFilterValue & "'"
frm.Filter = strFormFilter
frm.FilterOn = True
Else
frm.Filter = ""
frm.FilterOn = False
End If
ExittglApplyFilter_Click:
Exit Sub
ErrtglApplyFilter_Click:
MsgBox Err.Description
Resume ExittglApplyFilter_Click
End Sub
Any suggestions would be greatly appreciated!
I have an unbound main form with a bound (to an SQL statement) subform. The
subform's SQL statement has a field called 'Posted' which uses the value of
an unbound option group on the main form to select the appropriate records
(1=No, 2=Yes). The OptionGroup_AfterUpdate event requeries the subform and
works perfectly. The problem occurs when I apply a filter to the form and
then unapply the filter. When I apply the filter (filtering on a field
called 'Vendor') it still gives the desired results; i.e. I can click on the
option group and get the Posted or Unposted records for the selected Vendor.
When I remove the filter the subform displays all the records for Posted (if
that was originally selected when the filter was applied) or Unposted (if
that was originally selected). But if I click the other option nothing
happens. Very frustrating. Here is my code:
My subform's SQL statement:
SELECT APHeader.APHdrRID, APHeader.Vendor, APHeader.Name, APHeader.Invoice,
APHeader.InvoiceDescription, Choose(APHeader!InvoiceType,"Invoice","Credit
Memo") AS InvoiceType, APHeader.InvoiceDate, APHeader.DueDate,
APHeader.DiscountDate, APHeader.InvoiceAmt, APHeader.Posted
FROM APHeader
WHERE (((APHeader.Posted)=CStr([Forms]![APInvoiceMain]![optPostingStatus])));
My option group code:
Private Sub optPostingStatus_AfterUpdate()
On Error GoTo ErroptPostingStatus_AfterUpdate
Dim frm As Form
Set frm = Forms!APInvoiceMain!subfrmAPInvoiceMainSub.Form
frm.Requery
ExitoptPostingStatus_AfterUpdate:
Exit Sub
ErroptPostingStatus_AfterUpdate:
MsgBox Err.Description
Resume ExitoptPostingStatus_AfterUpdate
End Sub
My filter code:
Private Sub tglApplyFilter_Click()
On Error GoTo ErrtglApplyFilter_Click
Dim frm As Form
Dim strFilterField As String
Dim strFilterValue As String
Dim strFormFilter As String
Set frm = Forms!APInvoiceMain!subfrmAPInvoiceMainSub.Form
If Me!tglApplyFilter.Value Then
strFilterField = Me!cboFilterField
strFilterValue = Me!cboFilterValue
strFormFilter = "[" & strFilterField & "] = '" & strFilterValue & "'"
frm.Filter = strFormFilter
frm.FilterOn = True
Else
frm.Filter = ""
frm.FilterOn = False
End If
ExittglApplyFilter_Click:
Exit Sub
ErrtglApplyFilter_Click:
MsgBox Err.Description
Resume ExittglApplyFilter_Click
End Sub
Any suggestions would be greatly appreciated!