Update not immediate?

  • Thread starter Thread starter Reggie Laffond
  • Start date Start date
R

Reggie Laffond

My application starts on a continuous form that lists names of people who
need to be called. Its control source is a query that selects only records
where the yes/no field named "complete" is valued No. When a record is
selected (by clicking a command button on the desired row) a single record
form is opened displaying only the record selected on the continuous form
and the continuous form is closed in code. After the user finishes the call
the user clicks a command button on the single form indicating that the call
has been made. In code I open a recordset, seek the record being displayed,
edit the recordset, set the yes/no field "complete" to Yes and update the
recordset. Then I close the recordset object, close the database object,
close the single form and open the continuous form.

Set db = CurrentDB
Set rs = db.OpenRecordset("tblAll", dbOpenTable)
rs.Index = "PrimaryKey"
rs.Seek "=", Me.txtAccount
If Not rs.NoMatch Then
rs.Edit
rs.Fields("Complete") = True
rs.Update
End If
rs.Close
db.Close
DoCmd.Close , "frmSingleRecord"
DoCmd.OpenForm "frmListRecords"

When "frmListRecords" opens, the record that I just updated the "complete"
field to Yes is displayed but shouldn't because the query that feeds it has,
as part of its criteria, that "complete" must be No. If I close the
continuous form and open it 2 seconds later the record in question does not
display (and it should not).

It almost seems that after the single form updates the "complete" field to
Yes, the continuous form opens too quickly before the update is actually
finished.

Is that possible? Is there a way I can wait until the update is finished
before opening my continuous for?

Thanks in advance.
 
So, frmListRecords is the continous form? I see it being
opened, but never closed first. I would change your code
to this:

CurrentDB.Execute "Update tblAll Set Complete = True where
AccountNbr = " & Me.txtAccount
'Or, if AccountNbr is a text field
'CurrentDB.Execute "UPdate tblAll Set Complete = True
where AccountNbr = '" & Me.txtAccount & "'"
DoCmd.Close acForm, "frmSingleRecord"
Forms("frmListRecords").Requery


Chris
 
First, you definitely should not do the db.Close. You did not .Open that
database reference, you definitely should not .Close it.

As for the actual problem, I'd be wondering whether the continuous form is
actually< closing. Looking at the code you have quoted, it is clear that
you are happy to close the executing form, but then proceed with further
statements. Are you sure the continuous form does not close itself, but then
proceed with further statements? In that case, maybe when the single form
re-opens it, it is actually already open - hence the query has not refreshed
from the table.

If that doesn't help, perhaps a Requery in form_load? (though I'd be
surprised if that fixed it)

HTH,
TC
 
Back
Top