By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,044 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,044 IT Pros & Developers. It's quick & easy.

Maintaining selected record on requery

P: 2
Windows XP
MS Access 2000

Hello folks. First timer here. Have a problem with a form.

I am trying to open a report using a button on a form. The report will use information from a table which is particular to the record being viewed on the form at the time. I want to include any data that the user has input into the form directly before clicking the button. For this reason, I am using the requery function in the macro before opening the report. The trouble is, that this sends the form back to record no. 1.

This is part of a wider problem for me. It is essential on this form that all information and all coded calculations are completed before various reports are opened. I have even included a 'Calculate' button on the form to re-run any code and ensure that all data is current before reports are generated. The trouble is that the user has to remember to click this before printing anything.

I have been trying to get around the problem with non-record specific reports by closing the form and opening it again via macro. This is not a very classy way of doing things, but I'm a bit stuck. I suppose the short summary is: Is there a way of updating the table data from a form(just like you do when you move from one record to another) directly before generating a report and without changing the record in view?
May 7 '07 #1
Share this Question
Share on Google+
4 Replies


missinglinq
Expert 2.5K+
P: 3,532
DoCmd.RunCommand acCmdSaveRecord

will save the record to the table. Place it as the first line of code behind the button that opens the report.
May 7 '07 #2

JConsulting
Expert 100+
P: 603
Windows XP
MS Access 2000

Hello folks. First timer here. Have a problem with a form.

I am trying to open a report using a button on a form. The report will use information from a table which is particular to the record being viewed on the form at the time. I want to include any data that the user has input into the form directly before clicking the button. For this reason, I am using the requery function in the macro before opening the report. The trouble is, that this sends the form back to record no. 1.

This is part of a wider problem for me. It is essential on this form that all information and all coded calculations are completed before various reports are opened. I have even included a 'Calculate' button on the form to re-run any code and ensure that all data is current before reports are generated. The trouble is that the user has to remember to click this before printing anything.

I have been trying to get around the problem with non-record specific reports by closing the form and opening it again via macro. This is not a very classy way of doing things, but I'm a bit stuck. I suppose the short summary is: Is there a way of updating the table data from a form(just like you do when you move from one record to another) directly before generating a report and without changing the record in view?
Try using

IF me.dirty = true then
me.dirty = false
end if

it commits the record you're on.
May 7 '07 #3

missinglinq
Expert 2.5K+
P: 3,532
BTW, if you ever have to requery and want to return to the record you started out in
Expand|Select|Wrap|Line Numbers
  1. Dim holdID
  2. holdID = Me!YourPrimaryKeyName
  3.    Me.Requery
  4.    Me.Recordset.FindFirst "YourPrimaryKeyName = '" & holdID & "'"
May 7 '07 #4

P: 2
Thanks guys. That gives me a much better chance.
May 8 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.