I would like my form to show current record after selecting command button to print preview current record on a report. I am not sure how to do this.
Can someone please help?
Thanks in advance,
billgyrotech
I would like my form to show current record after selecting command button to print preview current record on a report. I am not sure how to do this.
Can someone please help?
Thanks in advance,
billgyrotech
probably not enough info to answer your post. a command button that would open a report in print preview does not inherently affect the record selected of a form - it might if one adds some vba in that button event - however that isn't clear.
if what you mean is that you are looking at a record in a form - and then you want the report to open to this same record - - then in this case the key to resolving your issue is that the report's record source must correspond to the value of the record in the form; probably via a query as the record source that has a criteria using a value from the form.
Hope this helps.
My button previews the current record on a report but when I close the preview, my form displays the first record and not the current record.
Sounds like the form is being requeried for some reason. Is there any code for requerying either in the code that opens the report or in the report's close event?
I am not sure.
Are you using VBA or macros? Take a look at whatever you are using to open the report and see if anything says REQUERY. If so, then that is what you are looking for. If you are running a macro or have VBA code in the report's ON CLOSE event, then look there as well.
If you still aren't sure, run Compact and Repair, zip the file by right-clicking on it and selecting SEND TO > COMPRESSED FOLDER and then upload a copy of it here. Make sure you don't include any sensitive data, but use bogus data instead so we can take a look.
Opening and closing a report shouldn't affect the record the form is on. If you're requerying, perhaps this:
http://www.baldyweb.com/Requery.htm
Sorry, had this open for a while after the boss came up to talk to me.
Where can I attach the file?
The instructions for doing it here are the same as over on this other site:
http://www.access-programmers.co.uk/...d.php?t=140587
I have attached the zip file. When opening, select Workorder button and then on that form there are 3 Preview buttons for reports. Whenever I select a button the form reverts back to the first record. I don't know why this happens but is there a way to remain on the current record?
Last edited by billgyrotech; 08-09-2011 at 03:13 PM.
Yep, you have this:
Me.Requery
in the form's On Activate event. That is what is causing your problem.
How to correct this?