PC Review


Reply
Thread Tools Rate Thread

Refresh & Goto Last

 
 
=?Utf-8?B?WmlsbGE=?=
Guest
Posts: n/a
 
      11th Jul 2006
Hi ,

I have a pop up form which allows users to add a new record. When the popup
is closed, I have a Requery run at OnClose so that the Main Form
("frmcypNew") is updated with the new record. This works fine.

What I want to do is: have it so that the main form (which shares a
recordsource with the popup) will goto the Last Record (ie the new one) when
the popup closes.

I have tried:
DoCmd.GoToRecord acDataForm, "frmcypNew", acLast
in the OnClose, Deactivate and Unload events on the popup form - nothing
happens.

I have tried:
DoCmd.GoToRecord acLast
in the GotFocus event of the mainform - to no avail - and the same in the
Current event of the main form - This does work, but causes problems when
trying to view any records other that the newly entered (ie makes it
impossible).

What code do I need and where?

Thanks in advance
Jim


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFycnkgR2lsYmVydA==?=
Guest
Posts: n/a
 
      11th Jul 2006
In the code in the main form, open the popup form in dialog mode. The
Docmd.OpenForm method has a parameter called WindowMode that allows you to
open it this way. The advantage is that this code waits until the popup form
is closed to continue executing. This allows you to do this:

DoCmd.OpenForm "frmAddRecord", WindowMode:=acDialog
DoCmd.RunCommand acCmdRecordsGoToLast

The 2nd line won't execute until frmAddRecord has closed.

HTH,
Barry

"Zilla" wrote:

> Hi ,
>
> I have a pop up form which allows users to add a new record. When the popup
> is closed, I have a Requery run at OnClose so that the Main Form
> ("frmcypNew") is updated with the new record. This works fine.
>
> What I want to do is: have it so that the main form (which shares a
> recordsource with the popup) will goto the Last Record (ie the new one) when
> the popup closes.
>
> I have tried:
> DoCmd.GoToRecord acDataForm, "frmcypNew", acLast
> in the OnClose, Deactivate and Unload events on the popup form - nothing
> happens.
>
> I have tried:
> DoCmd.GoToRecord acLast
> in the GotFocus event of the mainform - to no avail - and the same in the
> Current event of the main form - This does work, but causes problems when
> trying to view any records other that the newly entered (ie makes it
> impossible).
>
> What code do I need and where?
>
> Thanks in advance
> Jim
>
>

 
Reply With Quote
 
 
 
 
Stefan Hoffmann
Guest
Posts: n/a
 
      11th Jul 2006
hi,

Zilla write:
> I have a pop up form which allows users to add a new record. When the popup
> is closed, I have a Requery run at OnClose so that the Main Form
> ("frmcypNew") is updated with the new record. This works fine.
>
> What I want to do is: have it so that the main form (which shares a
> recordsource with the popup) will goto the Last Record (ie the new one) when
> the popup closes.
>
> I have tried:
> DoCmd.GoToRecord acDataForm, "frmcypNew", acLast

The new record is not necessarily the last record.

> What code do I need and where?

If you have an unique ID you can use the following function:

Public Function FormRequery(AForm As Access.Form, _
Optional AID As Long = 0 _
) As Boolean

On Local Error Resume Next

Dim ID As Long

If AID = 0 Then
ID = AForm![ID]
Else
ID = AID
End If

AForm.Painting = False
AForm.Requery
With AForm.RecordsetClone
.FindFirst "ID = " & ID
If Not .NoMatch Then
AForm.Bookmark = .Bookmark
End If
End With
AForm.Painting = True

FormRequery = True

End Function

with
FormRequery Forms("frmcypNew").Form, ID

Another solution before closing your popup:

Forms("frmcypNew").Form.Requery
Forms("frmcypNew").Form.Bookmark = Popup.Bookmark
DoCmd.Close acForm, "PopupForm"

mfG
--> stefan <--
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Just replace BUS!="usb*", GOTO="libgphoto2_rules_end" with "SUBSYSTEM!="usb_device", GOTO="libgphoto2_rules_end" luisortizhome@yahoo.com Windows Vista General Discussion 3 10th Sep 2007 07:46 AM
On Error Goto doesn't goto =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 1 15th Oct 2004 03:51 PM
On Error Goto doesn't goto =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 0 15th Oct 2004 03:05 PM
refresh refresh refresh refresh JP Microsoft Powerpoint 1 15th Aug 2003 04:44 AM
two field on the form goto another field then goto table M. Shahab Microsoft Access 0 14th Jul 2003 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 PM.