Results 1 to 11 of 11
  1. #1
    mnsemple83 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    40

    Retaining current record.

    A form for my database contains a button that will open a report in preview mode. When the user leaves preview mode, it returns them to the previous form. However, it will not display the record that the user was viewing before she opened the report and instead displays the first record in the database. How do I retain that record so that it doesn't change when the user leaves the report?

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Look in your Form's Properties -> Events -> OnActivate and see if there is a Me.ReQuery.

    If so - that is 're-setting' the Form to display the first record in the Table.

    If not, see if you can find the 'ReQuery' keyword either in one of your Form's Events - or in the code that is executed when you close your Preview.

  3. #3
    mnsemple83 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    40
    I eliminated all code containing "Requery" but the problem still exists.

    Is there a way to create a variable that can be used throughout the database?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Are you closing your form when you open the report or leaving it open?

    If you're closing the form, just leave it open when you close the report it should go back to the record you were on since you've already said you are not performing any requery/refresh function.

  5. #5
    mnsemple83 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    40
    Yes, I am closing the form when I open the report.

    In my code, I did not write any command for closing the main form. I am opening the report in print preview and that's when the main form closes automatically.

    Prior to the report appearning, a dialog box appears with the main form in the background asking the user to select data for the report. Once the user clicks 'OK', the main form and the dialog box close, and the report is displayed.

  6. #6
    mnsemple83 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    40
    I am thinking of writing a function that can be used by all objects in the database. I want this function to store the record before the form closes and once the user closes the report, the function gets that record and returns it to the database so that the record is displayed.

    Is this an efficient solution?

  7. #7
    APD is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    3
    I don't know if this helps, but I have a database with a form which has a button to open a report. My database uses a switchboard, and my form is set to open in add mode rather than edit mode, therefore the user can enter records, but is unable to access existing records through the form. The user can use the button to open the report, and when the report is closed the user is right back on the entry form where they left off.

    Hope this helps

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You do not need to close the Form. Just set it invisible and use the acDialog argument of the OpenReport command to halt the code in the first form. Then set the Form visible when the code returns.

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    As RG said, you don't need to close the form at all, just open the report in print preview, when you close the report it will go right back to where you were on the previous form.

  10. #10
    mnsemple83 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    40
    I just set the form to be invisible when the button is clicked and when the form is re-opened, I made it visible. The same record reappears so it worked. Thanks.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad we could help. Thanks for posting back with your success.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. No current record.
    By harmankardon in forum Programming
    Replies: 5
    Last Post: 08-11-2011, 05:48 AM
  2. Remain on Current Record
    By billgyrotech in forum Forms
    Replies: 17
    Last Post: 08-08-2011, 12:15 PM
  3. Report from current record
    By billgyrotech in forum Reports
    Replies: 18
    Last Post: 07-26-2011, 03:39 PM
  4. copy current record to new record
    By er_manojbisht in forum Forms
    Replies: 1
    Last Post: 02-27-2010, 05:31 PM
  5. Replies: 3
    Last Post: 02-13-2008, 09:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums