why when I press Enter key while a report is open, access exits and creates a back up?? (1 Viewer)

MuhamadNadir

New member
Local time
Tomorrow, 01:26
Joined
Apr 8, 2023
Messages
3
hello dears,
while a report is open in view-report mode (and there is button to print the report) , I press the enter key, the access exits and creates a backup file.
I want to make the button a default (like on a form) so I can print the report (in view-report mode) by pressing the Enter key!
can you please teach me how to print a report (in view mode) be pressing the Enter key instead of clicking on the print-button?
thank you very much
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,189
The situation of Access exiting and creating a backup file says that something else is wrong. That behavior indicates that Access crashed on you. Do you get any kind of error message? If you have warnings disabled, you need to enable them (at least during debugging of this problem) to see what the error message is trying to tell you.

The problem with just hitting the ENTER key is that there is normally no "natural" place in the open report to trigger an event, which is what you would need, and you normally do not place command buttons in the report itself. Not sure if a command button would actually work in that context because you would also need to give it focus. I know for a fact that reports before Ac2003 are NOT interactive so you can't do this directly. Not sure about more recent Access versions, but generally speaking, forms are interactive and reports are not.

If you opened the report from a form action, then the DoCmd.PrintOut would print it for you from events in the form. However, if the form is open full-screen, the form might not be visible at the time.


On the other hand, If you hit CTRL/P while the report is open in Print Preview mode, that would open the printer dialog box, after which you COULD just hit the ENTER key to trigger a printout.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:26
Joined
Sep 21, 2011
Messages
14,310
@ The_Doc_Man
I have two buttons on one of my reports. One t o close the report and one to create PDF.
However, I click the buttons when needed.

1680965127402.png
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,189
@ The_Doc_Man
I have two buttons on one of my reports. One t o close the report and one to create PDF.
However, I click the buttons when needed.

View attachment 107435

I am not surprised; that merely means you are on a more recent version than Ac2003, because the references I found said that in Ac2003, all reports were passive, not interactive. The OP just wants to hit "Return" in order to print and any solution for that request is going to include knowing how the report was opened and where Focus is located. Some combinations of the answers to those two questions will not work as originally requested.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:26
Joined
Sep 21, 2011
Messages
14,310
Well I can get the Enter Key to call the pdf button by setting focus to it on report load and it's keypress event, but get an error
1680975766541.png

as I am trying the line below

1680975836280.png
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,189
I was afraid that would still be the case - that reports are limited in what they can do.

@MuhamadNadir - thanks to @Gasman's experiment, I can tell you that your options are going to be strictly limited. The problem is Focus, and the report apparently doesn't cooperate that well with focus-related actions. Hitting the Enter key is one such action. I think my original solution of using CTRL/P and then Enter is the closest I know how to come. Perhaps another member will find an alternate solution, but I have done a couple of quick searches and this is all I can find.
 

MuhamadNadir

New member
Local time
Tomorrow, 01:26
Joined
Apr 8, 2023
Messages
3
I was afraid that would still be the case - that reports are limited in what they can do.

@MuhamadNadir - thanks to @Gasman's experiment, I can tell you that your options are going to be strictly limited. The problem is Focus, and the report apparently doesn't cooperate that well with focus-related actions. Hitting the Enter key is one such action. I think my original solution of using CTRL/P and then Enter is the closest I know how to come. Perhaps another member will find an alternate solution, but I have done a couple of quick searches and this is all I can find.
thank you very much for your help. I have already created a button on the report and it prints the report well by clicking.
the major problem now is: why pressing the Enter Key quits the entire program and creates a backup file?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,189
I return to my original assessment. Something else is failing badly enough to cause Access to crash. If you turn on warnings before you attempt using the Enter key, you should get an error message. The text of that message would tell us a lot.

As a general rule, when trying to fix problems, you NEVER turn off warnings. An error message is annoying for users but a life-saver for developers.
 

apr pillai

AWF VIP
Local time
Tomorrow, 03:56
Joined
Jan 20, 2005
Messages
735
I am using Access 2016, have this problem of quiting and taking a Backup of the database, when I make some changes on the Form design or some changes in the Code then attempt to close the Form w/o saving the changes, it will prompt whether to save the changes or discard. If the save option is selected then Access hangs for a minute or so and goes for taking a backup of the database, rather than saving the changes.

If I save the changes first before attempting to Close the Form then no issues.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,189
I am using Access 2016, have this problem of quiting and taking a Backup of the database, when I make some changes on the Form design or some changes in the Code then attempt to close the Form w/o saving the changes, it will prompt whether to save the changes or discard. If the save option is selected then Access hangs for a minute or so and goes for taking a backup of the database, rather than saving the changes.

If I save the changes first before attempting to Close the Form then no issues.

I cannot tell you why because there may be a thousand specific reasons, but the general behavior of Access quitting after making an unrequested backup copy is a generally common response to Access thinking it is about to corrupt the database, or has just discovered corruption in the database. In caution and to assure maximum integrity, it triggers the auto-backup.

The action you suggested - closing a modified form and saying "Yes" to "Save changes?" - works OK for me in Ac2010, which is the latest version I have at home. When I was still working I had newer versions but had no reason to get a newer version for home use.
 

Users who are viewing this thread

Top Bottom