Solved Open Form on double click (1 Viewer)

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
Dear All

Double click on list box I am trying to open a form for particular record. Although form gets open but without any data (blank). I am using the following code:

Private Sub lstMatter_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmClientMatter", , , "[ClientID]=" & Me.lstMatter & " and [MatterID]=" & Me.lstMatter
End Sub

List box derives its data through this line of code from lstClient:

Private Sub lstClient_Click()

Me.lstMatter.Visible = True

Me.lstMatter.RowSource = "SELECT ClientID, MatterID, Address, TypeDesc, MatterStatus, AgreedPrice FROM" & _
" qryAlphaClientMatter WHERE ClientID = " & Me.lstClient & _
" Order By ClientID"

End Sub

Any help or suggestion will be highly appreciated.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:43
Joined
May 21, 2018
Messages
8,463
DoCmd.OpenForm "frmClientMatter", , , "[ClientID]=" & Me.lstMatter & " and [MatterID]=" & Me.lstMatter
So your client ID and MatterID are the same? That does not make sense to me.
 

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
So your client ID and MatterID are the same? That does not make sense to me.
No. Lets suppose Client ID = 1001 Matter ID is = 1
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:43
Joined
May 21, 2018
Messages
8,463
No. Lets suppose Client ID = 1001 Matter ID is = 1
Well that is not what this says.
"[ClientID]=" & Me.lstMatter & " and [MatterID]=" & Me.lstMatter

is the form you are opening a Parent Child. Client on the main and matters in the sub or is it simply a form of matters?
If the latter
"[MatterID]=" & Me.lstMatter.column(1)
if the former
"clientID = " & me.lstMatter.column(0)

If you need to open to the client ID master and move to the Matter ID in the sub then you can pass the MatterID by openArgs. Open to that client then in the load move to that matter.
 

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
Well that is not what this says.
"[ClientID]=" & Me.lstMatter & " and [MatterID]=" & Me.lstMatter

is the form you are opening a Parent Child. Client on the main and matters in the sub or is it simply a form of matters?
If the latter
"[MatterID]=" & Me.lstMatter.column(1)
if the former
"clientID = " & me.lstMatter.column(0)

If you need to open to the client ID master and move to the Matter ID in the sub then you can pass the MatterID by openArgs. Open to that client then in the load move to that matter.
Thank you for your reply. No forms are not parent and child.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:43
Joined
May 21, 2018
Messages
8,463
Then use the column property to get the correct client id and matter id. But you may just need matter id only
 

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
Then use the column property to get the correct client id and matter id. But you may just need matter id only
Thank you so much this line of code is working fine. Many thanks again
 

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
Then use the column property to get the correct client id and matter id. But you may just need matter id only
Thank you so much this line of code is working fine. Many thanks again
DoCmd.OpenForm "frmClientMatter", , , "[ClientID]=" & Me.lstMatter.Column(0) & " and [MatterID]=" & Me.lstMatter.Column(1)
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:43
Joined
May 21, 2018
Messages
8,463
That may work, but may be unnecessary. If the form you are open is based on a query relating Clients to Matters then just this should work
[MatterID]=" & Me.lstMatter.Column(1)
because each master ID is unique.

Keep in mind you can bind any column in the bound column property. If you bind the second column in the controls property sheet then
me.lstMatter
will return the value of the second column.
One confusing thing is in the property sheet the columns for the bound property are 1,2,3... in code the column property is 0,1,2...
 

shery1995

Member
Local time
Today, 15:43
Joined
May 29, 2010
Messages
71
That may work, but may be unnecessary. If the form you are open is based on a query relating Clients to Matters then just this should work
[MatterID]=" & Me.lstMatter.Column(1)
because each master ID is unique.

Keep in mind you can bind any column in the bound column property. If you bind the second column in the controls property sheet then
me.lstMatter
will return the value of the second column.
One confusing thing is in the property sheet the columns for the bound property are 1,2,3... in code the column property is 0,1,2...
You are absolutely right it works both way. I have changed it to second one. Thank you for your assistance.
 

Users who are viewing this thread

Top Bottom