Subform.Requery-problem is killing me.

C

Codebuster

Subform.Requery-problem is killing me.

In Access 97 i have a form with a subform on it. This subform is a
continuous form. Every record on this continuous form has a button do delete
that specific record. This operation is done by calling a public function
which opens the underlaying table of the subform (with the DAO methode) an
delete the specific record. After this deletion i want the subform only to
show dthe existing records in de table, so a command a requery of the
subform. If i open de main form and make no changes to the records in the
subform this operation works fine, but.....every record on the subform has
also a checkbox. If i click the checkbox and then call the public
delete-function by pressing the delete button of that record, Access tells
me that only a requery can be done afther the current field is saved. I
don't understant what's happening. Can anyone help me to solve this problem.
This is my deleting code:

Public Function WisAktieHand(AktieID As Long, Volgnummer As Long, AktieDate
As Date, AktieWhere As String, lblAktietekst As String, chkAktie As Boolean)

Dim dbs As Database
Dim rst As Recordset
Dim ctl As Control

Set ctl = Forms!frmplanning!frmPlanItem

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblRappel")

rst.FindFirst "AktieID =" & AktieID

With rst
.Delete
.Close
End With

ctl.Requery

End Function



Thank for any help, Edwin
 
M

Marshall Barton

Codebuster said:
Subform.Requery-problem is killing me.

In Access 97 i have a form with a subform on it. This subform is a
continuous form. Every record on this continuous form has a button do delete
that specific record. This operation is done by calling a public function
which opens the underlaying table of the subform (with the DAO methode) an
delete the specific record. After this deletion i want the subform only to
show dthe existing records in de table, so a command a requery of the
subform. If i open de main form and make no changes to the records in the
subform this operation works fine, but.....every record on the subform has
also a checkbox. If i click the checkbox and then call the public
delete-function by pressing the delete button of that record, Access tells
me that only a requery can be done afther the current field is saved. I
don't understant what's happening. Can anyone help me to solve this problem.
This is my deleting code:

Public Function WisAktieHand(AktieID As Long, Volgnummer As Long, AktieDate
As Date, AktieWhere As String, lblAktietekst As String, chkAktie As Boolean)

Dim dbs As Database
Dim rst As Recordset
Dim ctl As Control

Set ctl = Forms!frmplanning!frmPlanItem

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblRappel")

rst.FindFirst "AktieID =" & AktieID

With rst
.Delete
.Close
End With

ctl.Requery

End Function


As Mark pointed out, this is the long way around. But the
reason what you have doesn't work is that you're requerying
the control when you need to requery the form.

Set ctl = Forms!frmplanning!frmPlanItem.FORM

A half way step from what you have to what Mark suggested is
to use the subforms recordset clone instead of opening
another recordset:

With Me.RecordsetClone
If Not .EOF And Not .BOF Then
.Bookmark = Me.Bookmark
.Delete
End If
End With
Me.Requery
 
D

Dirk Goldgar

Marshall Barton said:
As Mark pointed out, this is the long way around. But the
reason what you have doesn't work is that you're requerying
the control when you need to requery the form.

Set ctl = Forms!frmplanning!frmPlanItem.FORM

Just a note, Marsh -- requerying a subform control does requery the form
object it's displaying.
 
M

Marshall Barton

Dirk said:
Just a note, Marsh -- requerying a subform control does requery the form
object it's displaying.


Why would it do that? Another one of those Access knowing
what you meant instead of doing what you said things, I
guess. ;-)

Thanks for straightening me out, Dirk.
 
E

e.kooijman1

Mark, Marshall, Dirk,

Thanks for your replay to my question. It did help me to stay alive
for a while. :)

Edwin
 

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