Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need KeyDown Help? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have the following code in KeyDown event on a datasheet form

    This code is not working on this line If Len(Me.strTranDesc) = 7 Then

    The operator enters 1234567 and presses the F4 Key

    The first MsgBox displays Y

    The length of strTranDesc is blank

    If I move the focus to next field then back to previous field as follows it works OK Me.lngCount.SetFocus
    Me.strTranDesc.SetFocus

    Is there a better way to handle this?

    Thanks, John


    <pre>MsgBox GetPref("DogTagIDRenewalNumber")
    If GetPref("DogTagIDRenewalNumber") = "Y" Then
    MsgBox "Len(Me.strTranDesc): " & Len(Me.strTranDesc)
    If Len(Me.strTranDesc) = 7 Then
    If Me.strRevCode >= "201" And Me.strRevCode <= "208" Then
    Me.strTranDesc = Left(Me.strTranDesc, 7) & "-" & _
    CalculateOriginalDAMCheckDigit(Left(Me.strTranDesc , 7))
    End If
    End If
    gloSetValue "LookupRenewalBy", "DogID"
    End If
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need KeyDown Help? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    When a control has the focus, use its Text property to get at the currently entered text. If you refer to the control, you actually refer to its default property Value. This is the stored value, which is not necessarily the same as the currently entered text. So use

    If Len(Me.strTranDesc.Text) = 7 Then

    etc.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need KeyDown Help? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Interesting, I think that explains why in the past I sometimes had to do an unnecessary DoCmd.RunCommand acCmdSaveRecord before being able to get the entered value I was looking for on a new record form.

    I

Posting Permissions

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