Filtering data after clicking in a listbox

G

Guest

Hello all,
the problem I encounter is probebly easy to solve, but I don't get it.
I have a form with a listbox. On the on-click event I startup a form with
datainformation related to the item in the listbox. So far so good.
Now I'm trying to display a subform with a 1 to many relation and filtered,
based on the item of the listbox.
When doing this, I see the subform but all the records of the table are
visible. It seems that de filter doesn't work at all.
How can I solve this.
Here is the code out of the subform:
Private Sub Form_Load()

If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If
Dim strSQL As String

If IsNull(Me.Mabc8) Then
' If the listbox is Null, use the whole table as the RecordSource.
Me.RecordSource = "tbl_1_OrdersToLate"
Else
strSQL = "SELECT DISTINCTROW tbl_1_OrdersToLate.* FROM
tbl_1_OrdersToLate " & _
"INNER JOIN Tbl_1_BasicMaterial ON " & _
"tbl_1_OrdersToLate.mabc8 = Tbl_1_BasicMaterial.mabc8 " & _
"WHERE (((Tbl_1_BasicMaterial.Mabc8)=""" & Me.Mabc8 & """));"

Me.RecordSource = strSQL
End If
' Apply the filter again, if it was on.
If bWasFilterOn And Not Me.FilterOn Then
Me.FilterOn = True
End If
If IsNull(Me.Mabc8) Then
Me.FilterOn = False
Else
Me.Filter = "mabc8 = """ & Me.Mabc8 & """"
Me.FilterOn = True
End If


End Sub
 
R

rbarfitt

Hi
Try requering your subform with the after update event in your combo
box

Bob
 
G

Guest

Hello Bob,

it seems so simple but...
I've tryed to put the refresh in the after update event and because it
didn't work I've placed it in the current event.
In both cases I receive an error message saying: Microsoft access can't find
the form 'myformname' referred to in a macro expression or Visual Basic code.

Any sugestions?
 

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

Top