If the recordset is empty, the detail section of the form will not
be initialised. So if there is a chance that the recordset will be
empty, make sure you put the record selection controls in the header
of footer of the form.
You want the form to open with one record, so if you are going to
alter the recordsource SQL, you need to do it in the form Open
event or before the form Open event. That means you must select
or determine the initial record before the CBO is visible.
You might save the last record visited (in a table, or in the
registry or in the saved querydef) If you do this, you need to
be careful if there is any change that the recordset might be
empty (see above).
Assuming you decide to re-open at the last saved record, you
might decide save the SQL when you do the selection from
the CBO.
If you have the SQL saved as the recordsource of the form, that
means you have to put the form (and the database) into design mode
to save the SQL. Which means that instead you want to use
a saved querydef as the source for the form.
So the coding will take place in the update event of the CBO, where
you might have something like (air code)
sSQL = codedb.querydefs(me.recordsource).sql
if instr(ssql,"where") then
sSQL = left(ssql,instr(ssql,"where"))
endif
sSQL = sSQL & "where idx = " & me.cbo
codedb.querydefs(me.recordsource).sql = ssql
me.recordsource = me.recordsource
me.requery
Is this similar to what you have tried?
(david)
> Hi David,
>
[quoted text clipped - 38 lines]
> > >
> > > thanks
Stuart - 27 Jan 2005 17:27 GMT
This is what I want to accomplish, I just didn't know how to go about it
without tearing into these forms and doing a lot of VB. I knew there had to
be an easier way without rewriting these forms.
I won't get a chance to try it until later, but it looks good.
Thanks David !
> If the recordset is empty, the detail section of the form will not
> be initialised. So if there is a chance that the recordset will be
[quoted text clipped - 84 lines]
> > > >
> > > > thanks