Move focus to row where duplicate item was originally captured

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    Move focus to row where duplicate item was originally captured

    I use this code to identify and delete new duplicate records, when as it is captured.
    I would like to Move the focus then to the row where a duplicate item was originally captured, in the subform (maybe a few lines up).
    Code:
    If DCount("[acquireid]", "tblAcquire", "acquireid<>" & acquireID & _
            " AND Client_lookup=" & Client_lookup & _
            " AND Item_Lookup=" & Item_Lookup & " AND Order_No=" & Order_no) > 0 Then
        msg = "This is a duplicate ICN code for this Facility Order. Please do not add duplicate entries" & vbNewLine
        msg = msg & "The record will now be undone"
        MsgBox msg, vbExclamation, "System Duplication Message"
        Me.Undo
        Cancel = True
    End If
    Please assist
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32668

    #2
    Depending on your exact requirement, you can use :
    1. Call DoCmd.GoToRecor d() to set the focus to the desired record.
    2. {SomeControl}.S etFocus() to set the focus to the desired control.
    3. {SomeForm}.SelT op to scroll the records within the visible list.
    4. {SomeForm}.Pain ting = True/False around your code to avoid visible flicker.

    Hopefully, with these tools, you have all you need to handle your situation.

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      thx Neopa will give a try

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32668

        #4
        Let us know how you get on. It can be fiddly, but with attention to the detail you can do all you want.

        Comment

        Working...