Results 1 to 11 of 11
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    End of Field (A2K)

    Quick question with probably an obvious answer.

    The form as I have it now allows me to, when entering a new record, press F5 in any field in order to duplicate the data in that field ( F01_Part_Serial_No ) from the previous record.

    So if the previous Serial No was 1749-001 and I press F5, I get 1749-001.

    Question: is there method whereby when I do press F5 and duplicate the previous entry, the cursor goes to the end of the field without destroying the previous data so that all that would be necessary to do would be to backspace one position to change the new serial number to 1749-002.

    It may on the surface appear to be a small thing, but when entering a few dozen sequential serial numbers in a row, it can lower the frustration factor.

    Thanks in advance for any help,
    Cheers,
    Andy

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

    Re: End of Field (A2K)

    If the focus is already in F01_Part_Serial_No:

    Me.F01_Part_Serial_No.SelStart = Len(Me.F01_Part_Serial_No.Text)

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

    Re: End of Field (A2K)

    You could make the code increase the serial number by 1, saving the user a bit of work.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Field (A2K)

    Hans,

    Thank heavens, quick as always. Tried the code but got a "Method or data member not found" on the ".Text" portion of your code. Hope I'm not missing something obvious.
    Cheers,
    Andy

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Field (A2K)

    Hans,

    That was my thought as well when I started on this particular problem. However, believe it or not, depending from whence comes the item, serial numbers can be increased by 2 or 5 depending upon the manufacturer.

    Don't ask!
    Cheers,
    Andy

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

    Re: End of Field (A2K)

    Is F01_Part_Serial_No the name of the text box?

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Field (A2K)

    Hans,

    The code looked like this the first time

    Private Sub txtSerialNo_GotFocus()
    Me.F01_Part_Serial_No.SelStart = Len(Me.F01_Part_Serial_No.Text)
    End Sub

    which gave me the Error code

    and then after your response it struck me that you were looking for the text box name and not the data name so I tried

    Private Sub txtSerialNo_GotFocus()
    Me.txtSerialNo.SelStart = Len(Me.txtSerialNo.Text)
    End Sub

    which partially worked in the sense that I did not get an error message, but instead, the field on the form is highlighted without the cursor going to the end, which is what I'm trying to accomplish.

    Thanks again,
    Cheers,
    Andy

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

    Re: End of Field (A2K)

    The modified code should work, unless you have other code that undoes the effect. But just in case, does this work better?

    Private Sub txtSerialNo_GotFocus()
    Me.txtSerialNo.SelStart = Len(Me.txtSerialNo.Text)
    Me.txtSerialNo.SelLength = 0
    End Sub

  9. #9
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Field (A2K)

    Hans,

    OK, this always gets interesting the deeper I go. Here
    Cheers,
    Andy

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Field (A2K)

    <img src=/S/smile.gif border=0 alt=smile width=15 height=15> YES!!!!!!!!! I guess I had the right idea, but not the knowledge to apply it correctlly.

    Thanks again,
    Cheers,
    Andy

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

    Re: End of Field (A2K)

    The user presses F5 while the focus is already on txtSerialNo, so the On Got Focus event doesn't occur. You'll have to make the code wait until the SendKeys instructiion is finished, and check in the function whether the active control is txtSerialNo.

    Public Function butDupeField()
    SendKeys "^'", True
    If Screen.ActiveControl.Name = "txtSerialNo" Then
    Screen.ActiveControl.SelStart = Len(Screen.ActiveControl.Text)
    End If
    End Function

Posting Permissions

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