List Box Up-Date

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I use a list box, (List4), to retrieve data in a form,
(Fees) and sub-forms, (Fees1, Fees2 & Fees3).
Can anyone tell me how to select the first record in the
list box and then re-query the form and sub-forms on
opening the parent form

Nick
 
Nick, When you open the parent form initially all of the forms/subforms are
automatically requeried. If however you are wanting to requery them after
making a selection in you list box you can use the On Click or After Update
event to do so

Private Sub myList_AfterUpdate()
Forms!Fees.Form.Requery
Forms!Fees!Fees1.Form.Requery
Forms!Fees!Fees1.Form.Requery
Forms!Fees!Fees1.Form.Requery
End Sub

This is assuming Fees1,2,3 are subforms of Fees form and not nested withing
each other.
 
Thanks Reggie,
I understand what you are saying.
The problem is to have the sub-forms return data on
opening. This dose not happen because I have to manually
click on the list box and then it re-queries after up-date.
I would like this to happen automatically.

The list box sets the criteria for the three sub-forms.

I hope this is clear and you can help.

Nick
 
Nick, From what I gather you have your subform's based on a query and those
queries are using the value you select in you listbox a criteria to filter
the records. When you first open the form no records are returned because no
value is set yet. I assume that you want to open the form and show all
records initially. If this is the case you can set the criteria in the query
that is using the listbox to something like this:

=Forms!yourformname!yourlistbox or Forms!yourformname!yourlistbox Is Null

Now when you open the form all records are shown.
 
Reggie,
Thanks for you patience.
What you have said is correct, except I don’t want to
return all records when the form is opened. I only want it
to return records as if I had clicked on the on the list
box.
That is, if I had clicked on the first name in the list
box before I had opened the form, I would expect to see
the records for that name when the form is opened.

I hope this clears up what I’m trying to do.

Nick
 
Nick in that case set the OnCurrent event of your form to something like
this. This will select the first item in the listbox and requery your
forms.


Private Sub Form_Current()
Me.YourListBox.Value = Me.YourListBox.ItemData(0)
Forms!Fees.Form.Requery
Forms!Fees!Fees1.Form.Requery
Forms!Fees!Fees1.Form.Requery
Forms!Fees!Fees1.Form.Requery
End Sub
 
Reggie,
Thank you very much.
I hope that that you get a lot of satisfaction out of what
you do. Because without people like yourself, people like
me would still be struggling.
I have been trying to find a way of doing this for weeks.
I appreciate you work and especially your patience.

Regards
Nick
 
Nick, These news groups have helped me out of many, many binds after
banging my head against the wall trying to resolve problems. After I
exhaust all my resources this is the where I come and they haven't let me
down yet. Therefore, anytime I can give back in anyway makes it all worth
while. Take care.
 
Back
Top