Updating continuous form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm going crazy. I have a form with two sub forms which are continuous forms.

In each subform I have a checkbox (bound to a yes/no field). I use the
checkbox to move the records between the subforms, acting like listboxes.

I select a couple of rows in the left box, click a button to move them to
the right hand box(form). The code behind the button runs a sql query
updating what box they belong to. This works fine. It also works fine when
moving them back. If I try to move the the second time it can't find a
recordset for the form using recordsetclone.

I know the underlying data for the form is changed when i run the update
query and I try to do Form.Requery right after the update but it still
doesn't work. After I run the update sql query what should I execute to
refresh the underlying data?
 
Rauken said:
I'm going crazy. I have a form with two sub forms which are continuous forms.

In each subform I have a checkbox (bound to a yes/no field). I use the
checkbox to move the records between the subforms, acting like listboxes.

I select a couple of rows in the left box, click a button to move them to
the right hand box(form). The code behind the button runs a sql query
updating what box they belong to. This works fine. It also works fine when
moving them back. If I try to move the the second time it can't find a
recordset for the form using recordsetclone.

I know the underlying data for the form is changed when i run the update
query and I try to do Form.Requery right after the update but it still
doesn't work. After I run the update sql query what should I execute to
refresh the underlying data?


Since the check box is bound, I don't unserstand what an
Update query has to do with it. AFAICS and assuming the
button is on the main form, you only need to requery both
subforms in the button click event:
Me.subform1.Form.Requery
Me.subform2.Form.Requery

If that's not sufficient, we will need to know what code you
are using.
 
Me.subform1.Form.Requery
Me.subform2.Form.Requery

Is what I've tried without any result.

I solved it. It seems like the subforms are loosing its recordsource in a
strange way. If I debug the code and in the debug.print window type
? me.subform.form.recordsource I get the correct sql code. However it can't
find a recordset from the recordsetclone. After updating the underlying table
I just update the recordsource:

me.subform.form.recordsource = "select xxx from...."
and it works! puh. It's delivery time tomorrow and this bug is the last (I
think).




"Marshall Barton" skrev:
 
Rauken said:
Me.subform1.Form.Requery
Me.subform2.Form.Requery

Is what I've tried without any result.

I solved it. It seems like the subforms are loosing its recordsource in a
strange way. If I debug the code and in the debug.print window type
? me.subform.form.recordsource I get the correct sql code. However it can't
find a recordset from the recordsetclone. After updating the underlying table
I just update the recordsource:

me.subform.form.recordsource = "select xxx from...."
and it works! puh. It's delivery time tomorrow and this bug is the last (I
think).

The Requery should be sufficient. Are you sure you are
using the name of the subform **control** (which may be
different from the name of the form it is displaying)?

Setting the RecordSource to itself is just an oblique way to
force the form to requery. If form's RecordSource property
is somehow being cleared so that you must reset the record
source to its original SQL statement, that's a symptom of
something gone awry.
 
Yes I use the control name of the subforms.

I run two update queries not just one. I'm trying to requery after each but
it doesn't work. The weird thing is that when I do this:

set rs = forms!frmsub.form.recordsetclone

The recordset is empty although if I debug and print the recordsource of the
form I get the correct sql. Strange.

It's working now and I'm not touching it :-)



"Marshall Barton" skrev:
 
Back
Top