473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Maintaining selected record on requery

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
4 9549
missinglinq
3,532 Expert 2GB
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
603 Expert 512MB
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
3,532 Expert 2GB
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
Thanks guys. That gives me a much better chance.
May 8 '07 #5

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

Similar topics

17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
7
by: ChrisR | last post by:
Hi guys My app is a simple Main form with a few Subforms that are not linked, and a few pop forms. Problem is: I have a pop form with a Listbox with a list of records related to the...
3
by: RC | last post by:
I have a form where the user enters the Model info. The user picks the Model from either a combobox or listbox which both are filled from the Models table. If the Model type isn't in the boxes,...
20
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
2
by: Arnold | last post by:
Hi Gurus, I am getting the error 3420 "object invalid or no longer set" at in the line -- rst.FindFirst "=" & NextPK --in the code below. I simply have a continuous main form that is, by...
23
by: csolomon | last post by:
Hello: I have a form that allows me to add new records. In the onCurrent event, I have: Private Sub Form_Current() 'Requery Job Number Me.cbojobNumber.Requery 'Requery DM_Mix Combo...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.