How do i check which listbox was double clicked?

papic1972

Registered User.
Local time
Today, 13:16
Joined
Apr 14, 2004
Messages
122
I have 5 listboxes on one form, "frmDriverEdit".

The double click event in each of these listboxes opens the same form "frmLoadControlPanel".

I have a command button with a series of 'IF' statements that will fire code depending on which listbox was double clicked in frmDriverEdit.

Does anyone know how to check within my 'IF' statement on "frmLoadControlPanel" which listbox was double clicked on "frmDriverEdit"


I've tried using the following code in the first line of my 'IF' statement:

If Forms!frmDriverEdit!lstDrivera.ItemsSelected.Count > 0 Then
to do the check but it is not working correctly.

Can anyone help?:eek:
 
I would expect that to work, presuming the form is still open, but you could also use the OpenArgs argument of OpenForm to pass the name of the listbox to the second form.
 
You could simply pass the name of the listbox that was double clicked via the OpenArgs portion of the docmd.openform
 
I'm unfamiliar with using OpenArgs. Can you show me how to code this?
 
Your docmd.openform (in your On Double Click event) would look something like;
Code:
DoCmd.OpenForm "YourFormName", acNormal, , , acReadOnly, , [B]"ListBoxName"[/B]
The bolded section on the end is the OpenArgs and could be replaced with almost anything including a reference to the listbox in the form Me.ListBox.Name.

Now in the On Load Event of the form being entered, you would put something along the lines of;
Code:
If OpenArgs = "ListBoxName1" Then
     Do appropriate action for that list box
Else If OpenArgs = "ListBoxName2" Then
     Do appropriate action for that list box
Else IF OpenArgs = "ListBoxName3"Then
     Do appropriate action for that list box
Else
     Do appropriate action if non of the above conditions are met
End If
 
You would of course have to do a logical check for each of the list boxes and assign the appropriate action.
 
OpenArgs?!? Why didn't I think of that? :p
 
Ah yes!!! Thank you Paul & John, awesome!!! That worked!!
Thanks heaps!
 

Users who are viewing this thread

Back
Top Bottom