PC Review


Reply
Thread Tools Rate Thread

Cannot maintain reocrd position after re-query - help!

 
 
Rachel
Guest
Posts: n/a
 
      25th Jul 2008
Hi,

I have a hugeof a problem, I have a form called frm_Search and on
this
form I have a command button which opens a popup form (frm_Invoice),
I
have a command button on the popup form also, which when pressed re-
query's the form 'frm_Search'. This is to ensure that data entered
(frm_Invoice) is displayed in the 'frm_search' form.


However, once it has re-queried the record position (on the
frm_Search
form) goes back to the first record and not the record that has been
updated via the frm_Invoice popup form.


I understand from reading up on this issue, that when something is
re-
queried the bookmark doesn't work.


I am totally lost with this now and any help would be greatly
appreciated. I have tried scanning the net for record clone
information etc but I just seem to get even more confused


This is my code from the popup form command button (frm_Invoice):


Private Sub cmd_Save_Invoice_Click()


On Error GoTo Err_cmd_Save_Invoice_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
Forms!frm_Search.Requery


Exit_cmd_Save_Invoice_Click:
Exit Sub


Err_cmd_Save_Invoice_Click:
MsgBox Err.Description
Resume Exit_cmd_Save_Invoice_Click


End Sub


This is my code from the command button on the frm_Search form (which
opens the popup form):


Private Sub cmd_Invoice_Click()
On Error GoTo Err_cmd_Invoice_Click


Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "frm_Invoice"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_cmd_Invoice_Click:
Exit Sub


Err_cmd_Invoice_Click:
MsgBox Err.Description
Resume Exit_cmd_AddInvoice_Click


End Sub


Many Thanks


Rachel


 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      26th Jul 2008
The solution would be to store the value of the primary key before making
the requerying and then use it to reposition the form. In order to have a
better visual effect, it's better to first make a clone of the recordset and
use it to make the search; something like:

Dim rs As ADODB.Recordset
set rs = Me.Recordset.Clone

if (rs.BOF and rs.EOF) then exit sub

rs.MoveFirst
rs.Find .......
if (rs.EOF) then exit sub

Me.Bookmark = rs.Bookmark

You could also use the RecordsetClone method instead of Recordset.Clone;
however, there have been many reports of problem with this method in the
past when used in an ADP project. (The RecordsetClone method will cache the
recordset on the first call and reuses/returns the same recordset for each
subsequent call.).

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


"Rachel" <(E-Mail Removed)> wrote in message
news:88bf56d8-d945-4e53-8e82-(E-Mail Removed)...
> Hi,
>
> I have a hugeof a problem, I have a form called frm_Search and on
> this
> form I have a command button which opens a popup form (frm_Invoice),
> I
> have a command button on the popup form also, which when pressed re-
> query's the form 'frm_Search'. This is to ensure that data entered
> (frm_Invoice) is displayed in the 'frm_search' form.
>
>
> However, once it has re-queried the record position (on the
> frm_Search
> form) goes back to the first record and not the record that has been
> updated via the frm_Invoice popup form.
>
>
> I understand from reading up on this issue, that when something is
> re-
> queried the bookmark doesn't work.
>
>
> I am totally lost with this now and any help would be greatly
> appreciated. I have tried scanning the net for record clone
> information etc but I just seem to get even more confused
>
>
> This is my code from the popup form command button (frm_Invoice):
>
>
> Private Sub cmd_Save_Invoice_Click()
>
>
> On Error GoTo Err_cmd_Save_Invoice_Click
>
>
> DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
> acMenuVer70
> Forms!frm_Search.Requery
>
>
> Exit_cmd_Save_Invoice_Click:
> Exit Sub
>
>
> Err_cmd_Save_Invoice_Click:
> MsgBox Err.Description
> Resume Exit_cmd_Save_Invoice_Click
>
>
> End Sub
>
>
> This is my code from the command button on the frm_Search form (which
> opens the popup form):
>
>
> Private Sub cmd_Invoice_Click()
> On Error GoTo Err_cmd_Invoice_Click
>
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
>
> stDocName = "frm_Invoice"
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
>
> Exit_cmd_Invoice_Click:
> Exit Sub
>
>
> Err_cmd_Invoice_Click:
> MsgBox Err.Description
> Resume Exit_cmd_AddInvoice_Click
>
>
> End Sub
>
>
> Many Thanks
>
>
> Rachel
>
>



 
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
Maintain position in treeview? Magnusb Microsoft ASP .NET 2 10th Mar 2009 02:52 PM
How to maintain scroll position in textbox =?Utf-8?B?SldTMzE1?= Microsoft Access Form Coding 1 17th Jul 2005 04:16 PM
Can't maintain page position Carlos Microsoft ASP .NET 4 11th Apr 2005 05:11 PM
Difficult to maintain the scroll position..... ASP.Net and IE 6.0 Smith John Microsoft ASP .NET 1 31st Jan 2004 08:49 AM
Maintain scroll position in ASP.Net GrantS Microsoft Dot NET 2 19th Nov 2003 08:54 PM


Features
 

Advertising
 

Newsgroups
 


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