Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all, I have a form in which you 2

Status
Not open for further replies.

bozic12

MIS
Jan 23, 2003
48
US
Hi all,
I have a form in which you type in a parameter, then I have a button which produces a report based on the parameter, and then closes the form. Everything works fine, and I have the code in the click event of the button. Although not totally necessary, I'd like to have it in the enter event of the button so that the code executes when the user hits the enter key. BUT, when I do this, I get an error on the code Docmd.Close acForm, "BuilderSearch", acSaveNo with the error saying This action can't be carried out while processing a form or report event. I get this message if I put the close statement anywhere by the click event. Like I said, it's not a huge deal, but does anyone have any suggestions on how I can have the form close after the report runs? Thanks.

-Jeff
 
I don't believe the Enter event does what you think it does.

Per help: The Enter event occurs before a control actually receives the focus from a control on the same form.

What you really want is the KeyPress event:

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

Try this out. It may require a little more coding per specifying the Enter Key.
 
FYI if you didn't know: KEYCODE for the ENTER key is 13
Cheers
John
 
Ok, thanks for the info guys. I just had just noticed that the enter even of a command button runs when I press the enter key. It's always good to learn more tips.

-Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top