A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

requery after insert new record into a multipage form



 
 
Thread Tools Display Modes
  #1  
Old January 29th, 2007, 09:26 PM posted to microsoft.public.access.forms
FrankieNap
external usenet poster
 
Posts: 6
Default requery after insert new record into a multipage form

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

  #2  
Old January 29th, 2007, 11:18 PM posted to microsoft.public.access.forms
Perry
external usenet poster
 
Posts: 41
Default requery after insert new record into a multipage form

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

"FrankieNap" schreef in bericht
ups.com...
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



  #3  
Old January 30th, 2007, 01:37 AM posted to microsoft.public.access.forms
FrankieNap
external usenet poster
 
Posts: 6
Default requery after insert new record into a multipage form

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

On Jan 29, 6:18 pm, "Perry" wrote:
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

"FrankieNap" schreef in oglegroups.com...



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- Hide quoted text -- Show quoted text -


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.