Solved VBA sendkeys BACKSPACE

skdn71

New member
Local time
Today, 22:34
Joined
Jul 23, 2023
Messages
27
Please help me if I run the VBA below with form_load on the Listproduct form it works fine but if I run it from frmNav on Load_form Listproduct form it doesn't work



Code:
Private Sub Form_Load()
    ' Select the text in the textbox
    Me.txtSearch.SetFocus
    Me.txtSearch.SelStart = 0
    Me.txtSearch.SelLength = Len(Me.txtSearch.Text)
    
    ' Simulate a backspace key press
    SendKeys "{BACKSPACE}"
End Sub
 
Please define the term, "doesn't work".

What do you expect to happen?

What actually happens instead?
 
SendKeys "{BACKSPACE}" on txtSearch

When Listproduct form open frm frmNav
 
see photo
 

Attachments

  • photo.jpg
    photo.jpg
    46.3 KB · Views: 155
Why not just use
Code:
Me.txtSearch = ""
or
Me.txtSearch = Null
 

Users who are viewing this thread

Back
Top Bottom