I am having trouble with the setfocus command and I have done a bit of searching and it appears I am not alone but with my very limited knowledge of vba I cannot seem to work it out.
I have managed to get the following code (with help) but the setfocus in the Private Sub cmdnextski_Enter() is not working and after pressing enter a different button is selected on the form.
basically the form asks for a number and when enter is pressed I want the number and time to be written to the sheet. works fine using the click sub but not the enter sub.
here is the code
---------------------
Code
Private Sub cmdnextski_click()
ActiveCell.FormulaR1C1 = Format(Time, "Long Time")
Range(Cells(Application.ActiveCell.Row, _
Application.ActiveCell.Column + 1), Cells(Application.ActiveCell.Row, _
Application.ActiveCell.Column + 1)).Activate
ActiveCell.FormulaR1C1 = txtskinumber
Range(Cells(Application.ActiveCell.Row + 1, _
Application.ActiveCell.Column - 1), Cells(Application.ActiveCell.Row + 1, _
Application.ActiveCell.Column - 1)).Activate
txtskinumber.Value = ""
timingform.txtskinumber.SetFocus
End Sub
Private Sub cmdnextski_Enter()
ActiveCell.FormulaR1C1 = Format(Time, "Long Time")
Range(Cells(Application.ActiveCell.Row, _
Application.ActiveCell.Column + 1), Cells(Application.ActiveCell.Row, _
Application.ActiveCell.Column + 1)).Activate
ActiveCell.FormulaR1C1 = txtskinumber
Range(Cells(Application.ActiveCell.Row + 1, _
Application.ActiveCell.Column - 1), Cells(Application.ActiveCell.Row + 1, _
Application.ActiveCell.Column - 1)).Activate
txtskinumber.Text = ""
timingform.txtskinumber.SetFocus
End Sub
Display More
----------------------------------
Thanks in advance
Nathan