Requery form does not maintain other forms record position

R

Rachel

Hi,

I have a bit of 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.

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
 
S

Sylvain Lafontaine

Yes, your code must remember the value of the primary key for the current
row and use it to reposition it after the requery. Search this newsgroup
for Recordset.Clone for many example of how to reposition a form to a
specific row.

(Finally, a personal opinion here: the use of prefixes such as frm_ and the
use of the underline character in a name is a bad habit that most people
around here have ceased; as they both make your code harder to read by other
people.)
 
R

Rachel

Yes, your code must remember the value of the primary key for the current
row and use it to reposition it after the requery.  Search this newsgroup
for Recordset.Clone for many example of how to reposition a form to a
specific row.

(Finally, a personal opinion here: the use of prefixes such as frm_ and the
use of the underline character in a name is a bad habit that most people
around here have ceased; as they both make your code harder to read by other
people.)

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


























- Show quoted text -

Thanks, how would you suggest I name the forms if I do not use frm_?

Many thanks

Rachel
 
B

boblarson

I personally disagree about not using frm in the name of the form. I find
it helps me identify my objects faster and easier. I do not like using the
underscore though. I will use frmMyFormName or rptMyReportName, etc. in
order to quickly identify what I am working with.

--

Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP
Free Access Resources at http://www.btabdevelopment.com
 

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