disabling enter key while form is running

beach

New Member
Joined
Feb 1, 2004
Messages
38
I have a vba line which responds to a command button being clicked, and then opens a j-walk enhanced dataform add-in, as below:


Private Sub CommandButton1_Click()
Sheets("INDATA").Select
Application.Run "dataform2.xla!ShowDataForm"
Sheets("CURRENT JOBS").Select
End Sub

Wht I want to do is disable the "enter" key while the j-walk form is active, due to the reason that the form closes if you hit enter, rather than button within the form itself, and then renable the enter key when the macro takes me back to the main page (in my case, named "CURRENT JOBS"

There are times when a user will go to the sheet named "INDATA" and needs to be able to use the enter key just as normal, so I dont want to disable it permanently, only while the j-walk form is active


Any help

Thanks
 
Thanks for your help, guys, I see now how to go about the code you have suggested.

I think in fact however, there is a fundamental flaw in MY original expectations, in that the Application: run dataform code removes all the keystroke interactions from the worksheet and its associated codelines and shifts them to the dataform, which in turn relies on a click button on the form itself to return control to the worksheet(s). Thus I think in reality I will need to be in the dataform code to try and disable the enter key(s).

Thanks for your interest and perseverance, I have emailed John Walk who developed the j-walk dataform, and am going to have to sit patiently (if thats possible !) for a response.

Ta again

Beach
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Of course there is the obvious solution of just not hitting enter when the macro is running.
 
Upvote 0
Yeah appreciate that, problem is the other 20 - 30 users, and the consequences of adding numerous blank lines on the end of the data form (thats what happens when the enter key is hit, rather than the form "next" button), and trying to make the thing bullet proof >> some of the other users are way more hapless than I! Thanks
 
Upvote 0
When you use the code I posted to turn off the enter keys before calling the macro, is enter key still enabled durring the macro?
 
Upvote 0
Try something else.

Put in the code for disabling the enter key and remove the code for re-enabling it. Run the macro and when it finishes see if enter is still disabled. If not then there must be some code in the macro that is resetting it.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top