update current record of continuous form only

Gazza2

Registered User.
Local time
Today, 11:45
Joined
Nov 25, 2004
Messages
184
Hi all,

I have a continuous form that is bound to a query. It pulls the data from a table if certain fields are empty. If I update the fields that are empty a function is run to check if the data is valid and then moves to the next record.

This all works fine if I am working on the first record but if I select any other record and fill in the empty fields then it updates the first record.

The following code is what runs on the afterupdate event of the field that has been updated:

Code:
Dim Answer As String
Dim db As DAO.Database
Dim Rslt As DAO.Recordset
Dim RecNum as integer

Set db = CurrentDb()
Set Rslt = db.OpenRecordset("QryOutstanding")
Answer = CheckInvoiceExists(InvoiceNo)
RecNum = Me.CurrentRecord
MsgBox RecNum

Rslt.Edit
Rslt.Fields(9) = Answer
Rslt.Update
Rslt.Close
DoCmd.RunCommand acCmdSave
Me.Requery


I have added a message box to test what the current record is and this displays the correct record number but the field for this record is not the one that is updated.

Any help would be much appreciated

Gareth
 
Yes, the code is flawed. Since you're on the record, why not just update the form controls:

Me.TextboxName = Answer
 

Users who are viewing this thread

Back
Top Bottom