SOLVED

Close Button on Report - Set Focus but doesnt close report

Super Contributor

Hello Experts,

 

I have a report that opens and on load I set the focus to the close button on the report.  I want to be able to hit the enter key and close the report and although the button's focus is set (I verify by using the tab key to make sure it is set) it doesnt seem to activate the close button event that is attached to the close button.  

 

I have to manually grab the mouse and position the cursor above the button and click to close the report.  Hitting enter is much quicker. 

 

Its interesting to note that I can do this without any issues on a form but seems like there is something in a report that prevents the close button code from firing when I hit enter and the focus is set to the close button. 

 

thank you...let me know if any questions. 

3 Replies

@Tony2021 

 

Is it possible that the command button responds to a "Click" event, but not to an "Enter" event?

 

Does this technique work on a command button on a form?

What other trouble-shooting steps have you taken?

best response confirmed by Tony2021 (Super Contributor)
Solution
is your Report in Report View?
i think it is.
bring it again in design view.
on the Report Property Sheet->Event->Key Preview: Yes.
now add code to the Keypress event of the Form:

Private Sub Report_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call yourCommandButton_Click
End If
End Sub
Hi Arnel, that was it! Worked perfectly. thank you sir...

Hi George, I did try transferring the close code from the "On Click" to "On Enter" event to no avail. Maybe had something to do with not changing the Key Preview to "yes". thank you