Hi Nick,
Okay, lets try changing some of the code.
Change:
rs.FindFirst "[ContactID] = " & Str(Nz(Me![ContactsList], 0))
To:
rs.FindFirst "[ContactID] = " & Nz(Me![ContactsList], 0)
Now, in the vb editor, click in the left 'margin' beside this line:
Set rs = Me.Recordset.Clone
You should see a big 'dot' appear, this is a breakpoint.
When the event fires, you'll be taken into the editor.
You then press F8 to step through the code.
If you place your mouse over [ContactsList],
you should see the value of it.
Check to see if it's a valid value.
--
HTH
Dan Artuso, Access MVP
Nick Mirro said:
Hi Dan. ContactID is an autonumber field. The afterupdate code was
generated by the wizard. I have little knowledge of vb and am not
sure
how
to walk through code. Here is a summary of what I've done:
[frmDataExchange - Master]
Public Sub Form_Current()
Me![sbfrmContactInfo].Form![ContactsList].Requery
Form_sbfrmContactInfo.ContactsList_AfterUpdate
End Sub
[sbfrmContactInfo - Child]
[ContactsList - listbox]
Public Sub ContactsList_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ContactID] = " & Str(Nz(Me![ContactsList],
0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Hi,
As long as the contacts in the listbox are in the form's recordset,
which I assume from your previous post they are, there should be no
problem.
Is ContactId a string or number? I notice you're using Str to
convert
the
listbox value to a string. If it is a string, you need to delimit your
criteria
with quotes.
Have you stepped through the code to check the values of the variables?
--
HTH
Dan Artuso, Access MVP
Well clicking a row in the listbox (housed in the subform) doesn't cause
the
child forms to update. This seems to be the case when there is a
Master/Child link between the subform housing the listbox, and the
parent
form.
Nick
Here is the after update procedure for the listbox:
Public Sub ContactsList_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ContactID] = " & Str(Nz(Me![ContactsList], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Hi,
It is possible to call the listboxes's AfterUpdate event from your
main form. First, you have to go into the subform's code module
and make the event Public. Just change Private to public.
Then in the Current even of your main form put:
Form_frmCat.List5_AfterUpdate
Substitute your names.
My form name is frmCat and the listbox is List5
--
HTH
Dan Artuso, Access MVP
Hi Dan. Thanks for this info. This works with one exception. The
listbox
updates as I cycle the parent form, but the listboxes afterupdate
event
"Find the record that matches the control" is disabled.
Is it possible for the listbox to be updated by the changing parent
form,
while the subform housing the listbox gets updated by the row
selected
in
the listbox?
Nick
Hi,
The Row Source for the combo would have to be based on a
query with a criteria on the OrgId (or whatever you called it)
=Forms!Parentform!OrgId
You would then requery the list box in the current event of the
Parentform.
--
HTH
Dan Artuso, Access MVP
Can't seem to solve this.
Parentform = Organizations (one)
1st subform = Contacts (many)
Listbox = Contacts
The listbox resides in the first child subform.
The listbox's afterupdate event is set to "Find the record that
matches
the
control" (via wizard).
What I want:
1 When a record in the listbox is selected, the record
of
its
subform,
and all children subforms should be filtered to that listbox
selection.
(For some reason, this only works if I break the Master/Child
link
to
the
parent form)
2. When the parentmost form is cycled, the recordset in the
listbox
should reflect only the contacts for the organization being
displayed
(in
the parent form).
If I break the Master/Child link from parent form to the first
subform,
the
listbox works, but of course, cycling the parent form will not
change
the
listbox. If I leave the link in place, then the listbox becomes
deactivated.
Thanks,
Nick