refresh and return to record

  • Thread starter Thread starter johnlute
  • Start date Start date
J

johnlute

I've been looking all over for this but can't find anything. I use
2003 and have a form that I want to:
1. Create a new record.
2. Refresh the form and and then return to created record.

Does anybody have an idea how to do this?

Thanks!
 
johnlute said:
I've been looking all over for this but can't find anything. I use
2003 and have a form that I want to:
1. Create a new record.
2. Refresh the form and and then return to created record.

Does anybody have an idea how to do this?


Refreshing the form won't lose the currrent record pointer, so I guess
you're talking about requerying the form. Are you creating the record via
the form, or by some external method, such as running an append query?
Under what circumstances do you want to requery, and why?

The basic principle is to capture the primary key of the record you added,
then after requerying, do a FindFirst on the form's recordset to locate that
record again. Something like this:

Dim varKeyValue As Variant

varKeyValue = Me.PrimaryKeyField ' maybe

With Me
.Requery
.Recordset.FindFirst "PrimaryKeyField = " & varKeyValue
End With

If the key field is text, you have to build quotes around the key value for
the FindFirst criterion.

There are fine points to this; that's why I asked the questions above.
 
johnlute said:
Hi, Dirk! My nightmare continues. Thanks for the clarification!


Um, does that mean I helped, or that I didn't help? Do you have any
followup questions?
 
Back
Top