Form not updating

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a text box. When I call another form, and input data, the
original form is supposed to show the new data in this text box. It only
edits data. It won't update on new records. If I close the form and reopen
it, the data is there.

Can anyone help????
 
ANStech said:
I have a form with a text box. When I call another form, and input
data, the original form is supposed to show the new data in this text
box. It only edits data. It won't update on new records. If I
close the form and reopen it, the data is there.

Can anyone help????

After adding new data to the table from some other form, you have to
requery the original form to allow it to recognize that new records
exist. In the Close event of the other form (or AfterUpdate, if you
will be switching back and forth without closing forms), you can have
code that checks to see if the original form is open and, if it is,
requeries it. Similar to this:

If CurrentProject.AllForms("OriginalForm").IsLoaded Then
Forms!OriginalForm.Requery
End If
 
I did what you suggested, but now the original form displays record 1, I need
it to be at the record it started from.
 
ANStech said:
I did what you suggested, but now the original form displays record
1, I need it to be at the record it started from.

I don't have enough information to give really specific advice, but you
can capture the primary key of the form's current record before you
requery it, then reposition the form to that record. it might look
something like this:

Dim varKeyField As Variant

If CurrentProject.AllForms("OriginalForm").IsLoaded Then

With Forms!OriginalForm
varKeyField = !KeyField
.Requery
.Recordset.FindFirst "KeyField = " & varKeyField
End With

End If

The above code should work if KeyField is a numeric field. If it's a
text field, quotes must be added to the FindFirst criterion to surround
the value being sought. For example,

.Recordset.FindFirst _
"KeyField = " & Chr(34) & varKeyField & Chr(34)
 
Thanks Dirk,

Your answer worked for old records, Because I was bound to the same table
on both forms, NewRecords kept incrementing twice. Another user was able to
help me by toggling the Dirty property.

THANKS!!!!!!!!!!!!!!!
 

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

Back
Top