search subform on open

D

DDBeards

Help Please, I have a form that contains a continuous subform. The subform
contains a list of products that support the main form. There is a boolean
on the subform to show the last order. Only one of the records on the
subform has this boolean set to true. What I am trying to do is when the
form opens, loop through the subform and find the record number of the one
record set to true. I have written code that loops through the records until
it finds the match then displays that record number on the main form. It
works great only if I build in some sort of trigger (a button or boolean)
that I manually set once the form is loaded and displayed. I have tried
putting the code in the on open of both the main and subform with no luck,
and I tried it in both on load and even on active. Nothing seems to work.

Can someone please give me some advise on how to loop through a record set
of a sub form when the main form opens so I can display a value elsewhere on
the main form.

Thanks

DDBeards
 
D

DDBeards

One additional strange problem with this. When the code is put in the
on-open option of the sub-form and I use a "toggle breakpoint" to watch the
code it works fine also! I amlost for words
 
J

Jeanette Cunningham

Hi,
looping through a recordset is always slower than using a query or filter.
You could set a filter for the subform
You could change the query for the subform's record source by using a where
clause for the boolean field.

Jeanette Cunningham
 
D

DDBeards

Thanks for responding Jeanette, I actually got this to work by putting the
code in the event "On Enter" at the main form level. It works great. Your
solution was my first attempt and it did take care of half the problem.
Thanks again
 

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