Double Click

T

Todd

Hi,

I trying to double click a list box item so that it opens
another form containing information specific to the item
in the list box.

Can someone provide me with an example of the code used
to make this happen.

Thanks very much,
Todd
 
M

Mark A. Sam

Hello Todd,

Let us say the listbox is named, [MyListBox] which you want to coodinate it
with is [ID] both Long Integers, trto open MyForm.



Private Sub myListBox_DblClick(Cancel As Integer)

DoCmd.OpenForm "myForm", , , "[ID] = " & [myListBox]

End Sub




If you are dealing with Text fields:

DoCmd.OpenForm "myForm", , , "[ID] = '" & [myListBox] & "'"

Not I am surrounding the value with single quotes

If it is a date field:

DoCmd.OpenForm "myForm", , , "[ID] = #" & [myListBox] & "#"

I surrounded the date with # signs


TO make it more generic, you could use:

DoCmd.OpenForm "myForm", , , "[ID] = " & Me.ActiveControl

However this sometimes creates unexpected problems if the control doesn't
have the focus when the event fires. I don't know why that happens, but it
does occatiionally.

God Bless,

Mark A. Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top