refresh and return to record

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!
 
D

Dirk Goldgar

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.
 
D

Dirk Goldgar

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?
 

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

Top