Problem with Command Button and textbox.setfocus

chrisgoode

New Member
Joined
Jan 15, 2015
Messages
1
I have a simple excel spread sheet that I am using VBA to run a form. What I want to do is when the enter key is hit on the NextRecord button (which puts the entries into my spreadsheet) I want the focus to turn back to TextBox4. Instead the cursor is moving to the next command box. I know the reason for this is because I have code where I am substituting the tab key for the enter key but I can't figure out another way. This is going to be installed on a handheld with windows mobile so there is no capability for a mouse click. This is my first go at any programming so I greatly appreciate any help. Code snippets that I am using:
  1. Private Sub TextBox4_KeyDown(ByVal KeyCode As _MSForms.ReturnInteger, ByVal Shift As Integer)
  2. If KeyCode = 13 Then KeyCode = 9
  3. End Sub
  4. Private Sub NextRecord_Enter() Dim i As Integer
  5. TextBox4.Text = ""
  6. TextBox4.SetFocus
  7. End Sub
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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