requery after insert new record into a multipage form

F

FrankieNap

I have a multipage form that I use to input information on students,
look up test scores, etc.
I am using a popup form to add new students. On adding a new student,
the code inserts a new primary ID and I insert the student's first and
last name. If I want to cancel the student, I press one button which
deletes the current record and closes the pop-up form. If I want to
keep the student, however, I have another button which closes the pop-
up and requeries my main form. Here is the code:

DoCmd.Close acForm, "New Student"
Dim ctlCombo As Control

Set ctlCombo = Forms!Students!StudentNavigator
ctlCombo.Requery
Forms!Students.Requery

The "New Student" is the pop-up. The first requery is for a drop-down
list which I use to navigate, the second requery is supposed to
requery the control of the main form "Students". However, when this
requery runs, instead of staying on the first page of this 3 page
form, I am redirected to the middle of the second page. I have tried
to add a docmd.gotopage after the requery but to no avail.
If anyone has any advice it would be greatly appreciated.
On a second note, I wonder if there is a simple way to, after
requerying the main form, go directly to the new student whcih was
just added?
Thank you,
-Frank
 
P

Perry

How are the "pages" setup on yr mainform?
On a second note, I wonder if there is a simple way to, after
requerying the main form, go directly to the new student whcih was
just added?

Here's one method navigating to newly added student
assuming "StudentID" (long) is the Prim field
to table "tblStudent"and we're programming in the mainform
with same table as recordsource.

Dim rs as DAO.Recordset
set rs = me.RecordsetClone
rs.FindFirst "StudentID=" & DMax("StudentID", tblStudent)
if Not rs.NoMatch then
me.bookmark = rs.bookmark
end if

Krgrds,
Perry
 
F

FrankieNap

The pages are simply separated by page breaks. I have buttons on the
header which you click to gotopage 1, 2, or 3.
 

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