Setfocus on textbox

  • 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



    Thanks in advance

  • Re: Setfocus on textbox

    Hi Nathan

    Welcome to ozgrid

    Please use the code tags when posting code.This is one of the rules you agreed to when joining.

    I have added them for you this time. Please understand that future failure to comply with forum rules could see your posts deleted.

  • Re: Setfocus on textbox

    Hi nathan

    the set focus is usually of the syntax



    userfrom and textbox are the names given by you

    check out your syntax



  • Re: Setfocus on textbox

    In regards to your question, the Enter Event of any Control Object occurs before a control actually receives the focus from a control on the same form. Exit occurs immediately before a control loses the focus to another control on the same form.

    See the example below, which should help.

  • Re: Setfocus on textbox


    Sorry about the code tags :oops:

    But thank you VERY MUCH for the solution YAY works like a charm


    it is just a simple project to help the scorers at the jetski racing.. they will be VERY happy now..

    Thanks heaps

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!