Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2012
    Posts
    68

    Unanswered: GetFocus OnEnter issues

    So I have attached a view of my form. Here is some of the code:
    Code:
    Private Sub jobnumber_AfterUpdate()
    
        Const cQuote = """"  'Thats two quotes
        Me.jobnumber.DefaultValue = cQuote & Me.jobnumber.Value & cQuote
        taxstatus = DLookup("[taxstatus]", "jobs", "[jid] =" & Me.jobnumber)
            
    End Sub
    Code:
    Private Sub taxstatus_OnEnter()
        Const cQuote = """"  'Thats two quotes
        Me.taxstatus.DefaultValue = cQuote & Me.taxstatus.Value & cQuote
    End Sub
    So here is what i want to do. Since taxstatus is the end of the form tab order, when enter is pressed it submits the record. After this entry i want the cursor to be placed back into the Material textbox. this will allow for consecutive entries. When i place Me.materialtxt.GetFocus in the taxstatus_OnEnter i get an error. Am i going about this the right way? I am 3 weeks into learning Access on my own. Any help would be great.

    Thanks,

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Review the order of events in help. The Enter event is occurring as focus "enters" the textbox, not when the user presses "Enter" to leave it. In other words, before the user enters any data in the textbox. That also means your value is not being saved as a default as you'd expect. I'd probably use the after update event of the control. Frankly, with the correct tab order focus should go back to the first control anyway.
    Paul

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I'm confused, here! Why are you populating the taxstatus Control using

    Code:
    taxstatus = DLookup("[taxstatus]", "jobs", "[jid] =" & Me.jobnumber)
    and

    setting a Default Value for it, with

    Code:
    Me.taxstatus.DefaultValue = cQuote & Me.taxstatus.Value & cQuote
    Unless the jobnumber Field is sometimes left blank, setting the Default Value for taxstatus seems to be a wasted effort. Is the jobnumber sometimes left blank?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Mar 2012
    Posts
    68
    Quote Originally Posted by Missinglinq View Post
    I'm confused, here! Why are you populating the taxstatus Control using

    Code:
    taxstatus = DLookup("[taxstatus]", "jobs", "[jid] =" & Me.jobnumber)
    and

    setting a Default Value for it, with

    Code:
    Me.taxstatus.DefaultValue = cQuote & Me.taxstatus.Value & cQuote
    Unless the jobnumber Field is sometimes left blank, setting the Default Value for taxstatus seems to be a wasted effort. Is the jobnumber sometimes left blank?

    Linq ;0)>
    The taxstatus control uses dlookup after update of jobnumber. After jobnumber is entered for one item the value remains the same for consecutive entries. Therefore the after update does not trigger the taxstatus to be updated. So that code was placed to keep the taxstatus for consecutive entries. I could be going about this the wrong way but it's working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •