0

When I click the a command button to close the form, the code requery's a cbo and listbox, moves the focus to the lstbox and a particular row. What I need to do is add some code that "clicks" the current row in the listbox that has the focus.

Here is the code I have on the click event.

If Forms![frmmain]![txtHidden] = "addok" Then
Forms![frmmain]![cboAuthor].Requery
Forms![frmmain]![LstAuthor].Requery
Forms![frmmain]![LstAuthor] = Me.AuthorID
Forms![frmmain]![txtHidden] = "AddDone"
DoCmd.Close acForm, "frmAddAuthorFly"
Forms![frmmain]![cboAuthor].Requery
Forms![frmmain]![LstAuthor].Requery
Forms![frmmain].[LstAuthor].SetFocus
<NEED TO INSERT SOMETHING HERE TO CLICK THE ROW"

Else
MsgBox "txt hidden is not addok"
DoCmd.Close acForm, "frmaddauthorfly"
End If
  • Hi Gustav. Thanks for the pointer. I had some code in the after update event that I was wanting to run when I clicked the row in the listbox. I now have added that code directly to the cmd button and it works perfectly. I was making it more complicated than it needed to be. Again, thanks for your suggestion/answer. Regards – Nev in Redwood Dec 29 '15 at 21:06
  • Gustav, if you make your comment an answer, I will accept it. – Nev in Redwood Dec 29 '15 at 21:07
  • OK, that makes sense. Done. – Gustav Dec 29 '15 at 22:25

1 Answers1

0

A click does nothing by itself, but you may have some OnClick code that runs. To do so, just call the OnClick event.

But all this requiring - and indeed "clicking" - shouldn't be needed; it seems as if you need to rethink your concept.

Gustav
  • 53,498
  • 7
  • 29
  • 55