Find record after update (1 Viewer)

bodylojohn

Registered User.
Local time
, 23:58
Joined
Dec 28, 2005
Messages
205
Hello people...

I have a main form called frmCALCULATIE.

On that mainform there is a subform called frmCALCULATIEVERSIE

On the form frmCALCULATIEVERSIE there is also a subform called frmCALCULATIEREGEL.

Besides the subform frmCALCULATIEVERSIE there is another subform on the main form which is a datasheet where I put the following code:

Code:
Private Sub AddNew()
'Dim newID As Long
  Dim rst As dao.Recordset
  'add a record
  Set rst = CurrentDb.OpenRecordset("SELECT CalculatieRegel_ID, CalculatieVersie_ID, Werkzaamheden_ID, Eenheid_ID FROM tblCALCULATIEREGEL;")
  With rst
    .AddNew
    !Werkzaamheden_ID = Me.txtElement_ID.Value
    !CalculatieVersie_ID = Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].Form![txtCalculatieVERSIE_ID].Value
    !Eenheid_ID = Me.txtEenheid_ID.Value
       
    .Update
    .Close
  End With

  'requery the form
  
  Forms![frmCALCULATIE].Requery


[B]With Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].RecordsetClone
.FindFirst "CalculatieVersie_ID = " & Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].Form![txtCalculatieVERSIE_ID].Value
End With[/B]
End Sub

Except for the code in bold it works perfect. the record is added to the right table with the correct data.
However...after the requery the the datasaet goes to the first record but I wont it to go to the current record.
The code in bold is not working. What am I doing wrong?
 

bodylojohn

Registered User.
Local time
, 23:58
Joined
Dec 28, 2005
Messages
205
I think I ALMOST solved it.

I changed:

Code:
Forms![frmCALCULATIE].Requery


With Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].RecordsetClone
.FindFirst "CalculatieVersie_ID = " & Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].Form![txtCalculatieVERSIE_ID].Value
End With
End Sub

to

Code:
Forms![frmCALCULATIE]![frmCALCULATIEVERSIE].Requery

This works in the case that there is only 1 version (versie).

I it posible to requery the subnested form from a subform like this:
Forms![frmCALCULATIE]![frmCALCULATIEVERSIE] "THE SUBNESTED FORMNAME HERE" .Requery (what is the correct syntax for this?)
 

Users who are viewing this thread

Top Bottom