Requery causes record change

Rats

Registered User.
Local time
Today, 14:14
Joined
Jan 11, 2005
Messages
151
I have a Form [customers], which contains a tabbed control and within one of the tabs I have a subform [Loans]. The Loans form is a "display only" form which lists clients loans. The loans can be updated or added to by a popup form which acts as a loan calculator. The "After Update" event of the popup form requeries the [customers] form when the amended loan record is entered via the selection of a new record on the popup. This has the effect of displaying the changed loans on the underlying [loans] form.

This works OK except that the record being displayed on the customers form immediately jumps to the first record in the customers table.

Has anybody any thoughts on why it would jump records after the requery and how I could stop it.

The requery code is as follows

Code:
Private Sub Form_AfterUpdate()
Forms![customers].Requery
End Sub
 
Searching the forum is a great way to discover and learn how to program in Access.

Here is how I do it when I allow the user to recalculate the form. My primary key is the records SSN. Adjust it to meet your needs.

Code:
Private Sub bRecalc_Click()
On Error GoTo Err_bRecalc_Click

    Dim sSSN As String
    
    If Me.Dirty Then
        MsgBox "Please save this record before you attempt to requery the data!", vbExclamation, "Save Required"
        Exit Sub
    Else
        sSSN = tbSSN
        DoCmd.Echo False
        Me.Requery
        Me.tbSSN.SetFocus
        DoCmd.FindRecord sSSN
        DoCmd.Echo True
        sSSN = ""
    End If

    Me.tbHidden.SetFocus

Exit_bRecalc_Click:
    Exit Sub

Err_bRecalc_Click:
    DoCmd.Echo True
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bRecalc_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom