Sending a mouseclick event to a listbox programatically

cricketbird

Registered User.
Local time
Yesterday, 19:43
Joined
Jun 17, 2013
Messages
118
I have a form (about patients) containing a listbox (list of visit dates) and a subform (showing medications at that date). When you click on the listbox, the subform is re-queried with the selected date as a parameter to show the medications that were in use on that date. This is working fine.

However, when you move to a new record (patient), the subform is initially blank because the listbox hasn't been clicked on yet. This means that it looks like the person isn't on any medications, which is causing some confusion.

I need a way to have the subform show the "top" (most recent) date because that is the current medication list, and the thing most people want to see first. It is always the top of the list, so I would like to do something like this (pseudocode)

Code:
Private Sub Form_Current()
Forms![MedSearch].SelectDateBox.Requery
Send MouseClick Event to line 0 of SelectDateBox
End Sub

Can anyone help me put this into real code?
I'm open to other suggestions if there is a better way to do this.

Thank you,
CB
 
In your form oncurrent event, simply call the listbox click event e.g.

myListbox_Click
 
CJ_London,

I had to add a line of code to select the first line, and then your suggestion worked:
Code:
Private Sub Form_Current()
Forms![MedSearch].SelectDateBox.Requery
Me!SelectDateBox.Selected(0) = True
SelectDateBox_Click

End Sub

Thanks!
CB
 

Users who are viewing this thread

Back
Top Bottom