ListBox OnClick problem

B

Bob V

I have a list box with this row source
SELECT qryNoClient.HorseID, qryNoClient.Name FROM qryNoClient;

I want to be able to click on a row and get the frmHorseInfo, Through his
HorseID field!

Something like this:
Private Sub ListNoClient_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me![HorseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
P

Pieter Wijnen

stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value ?

Pieter

Bob V said:
Sorry Ken "No"
I am getting this error
myDBname cant find the field 'HorseID' referred to in your expression
Thanks for any help...............Bob

Ken Snell (MVP) said:
OK - is what you posted not working as you intended?

--

Ken Snell
<MS ACCESS MVP>


Bob V said:
I have a list box with this row source
SELECT qryNoClient.HorseID, qryNoClient.Name FROM qryNoClient;

I want to be able to click on a row and get the frmHorseInfo, Through
his HorseID field!

Something like this:
Private Sub ListNoClient_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me![HorseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
K

Ken Snell \(MVP\)

< grin > See Pieter's reply. He's got the right answer.

--

Ken Snell
<MS ACCESS MVP>


Bob V said:
Sorry Ken "No"
I am getting this error
myDBname cant find the field 'HorseID' referred to in your expression
Thanks for any help...............Bob

Ken Snell (MVP) said:
OK - is what you posted not working as you intended?

--

Ken Snell
<MS ACCESS MVP>


Bob V said:
I have a list box with this row source
SELECT qryNoClient.HorseID, qryNoClient.Name FROM qryNoClient;

I want to be able to click on a row and get the frmHorseInfo, Through
his HorseID field!

Something like this:
Private Sub ListNoClient_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me![HorseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
B

Bob V

Brillant Guys Thanks
Just one more problem now I am getting this error when i close frmHorseInfo
I am getting, "You cant hide a control that has focus"
Forms("frmMain")("ListNoClient").Requery

yellowline--->
Forms("frmMain")("ListNoClient").Visible =
IIf(Forms("frmMain")("ListNoClient").ListCount = 0, False, True)

End If
"Pieter Wijnen"
stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value ?

Pieter

Bob V said:
Sorry Ken "No"
I am getting this error
myDBname cant find the field 'HorseID' referred to in your expression
Thanks for any help...............Bob

Ken Snell (MVP) said:
OK - is what you posted not working as you intended?

--

Ken Snell
<MS ACCESS MVP>




I have a list box with this row source
SELECT qryNoClient.HorseID, qryNoClient.Name FROM qryNoClient;

I want to be able to click on a row and get the frmHorseInfo, Through
his HorseID field!

Something like this:
Private Sub ListNoClient_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me![HorseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
K

Ken Snell \(MVP\)

You'll need to move the focus to something other than the listbox on frmMain
before you try to make it invisible. I assume that there is another control
on that form that normally has the focus before the user goes to the list
box?


If Forms("frmMain")("ListNoClient").ListCount = 0 Then
Forms("frmMain").NameOfADifferentControl.SetFocus
Forms("frmMain")("ListNoClient").Visible = False
End If
 
P

Pieter Wijnen

move the focus to another control on that form

Pieter

Bob V said:
Brillant Guys Thanks
Just one more problem now I am getting this error when i close
frmHorseInfo
I am getting, "You cant hide a control that has focus"
Forms("frmMain")("ListNoClient").Requery

yellowline---> Forms("frmMain")("ListNoClient").Visible =
IIf(Forms("frmMain")("ListNoClient").ListCount = 0, False, True)

End If
"Pieter Wijnen"
stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value ?

Pieter

Bob V said:
Sorry Ken "No"
I am getting this error
myDBname cant find the field 'HorseID' referred to in your
expression
Thanks for any help...............Bob

OK - is what you posted not working as you intended?

--

Ken Snell
<MS ACCESS MVP>




I have a list box with this row source
SELECT qryNoClient.HorseID, qryNoClient.Name FROM qryNoClient;

I want to be able to click on a row and get the frmHorseInfo, Through
his HorseID field!

Something like this:
Private Sub ListNoClient_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me![HorseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
B

Bob V

Thanks Ken Brilliant :)
Works a treat!!
but how come when I do a Debug I get a compile error " Method or data member
not found , Below {{.ListNoClient}}
Private Sub tbClientName_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks Bob

End Sub
 
K

Ken Snell \(MVP\)

stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

should be

stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value

--

Ken Snell
<MS ACCESS MVP>



Bob V said:
Thanks Ken Brilliant :)
Works a treat!!
but how come when I do a Debug I get a compile error " Method or data
member not found , Below {{.ListNoClient}}
Private Sub tbClientName_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks Bob

End Sub
Ken Snell (MVP) said:
You'll need to move the focus to something other than the listbox on
frmMain before you try to make it invisible. I assume that there is
another control on that form that normally has the focus before the user
goes to the list box?


If Forms("frmMain")("ListNoClient").ListCount = 0 Then
Forms("frmMain").NameOfADifferentControl.SetFocus
Forms("frmMain")("ListNoClient").Visible = False
End If
 
B

Bob V

Sorry Ken the {{ }} was to show you what was blued out!! Oops thanks Bob

Ken Snell (MVP) said:
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

should be

stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value

--

Ken Snell
<MS ACCESS MVP>



Bob V said:
Thanks Ken Brilliant :)
Works a treat!!
but how come when I do a Debug I get a compile error " Method or data
member not found , Below {{.ListNoClient}}
Private Sub tbClientName_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks Bob

End Sub
Ken Snell (MVP) said:
You'll need to move the focus to something other than the listbox on
frmMain before you try to make it invisible. I assume that there is
another control on that form that normally has the focus before the user
goes to the list box?


If Forms("frmMain")("ListNoClient").ListCount = 0 Then
Forms("frmMain").NameOfADifferentControl.SetFocus
Forms("frmMain")("ListNoClient").Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>



Brillant Guys Thanks
Just one more problem now I am getting this error when i close
frmHorseInfo
I am getting, "You cant hide a control that has focus"
Forms("frmMain")("ListNoClient").Requery

yellowline---> Forms("frmMain")("ListNoClient").Visible =
IIf(Forms("frmMain")("ListNoClient").ListCount = 0, False, True)

End If
 
K

Ken Snell \(MVP\)

OK - well, have you changed the name of the listbox control to tbClientName?
If not, if it's still named ListNoClient, then I'm not understanding what
you're doing in your code any more. Originally, you were using the Click
event of the ListNoClient listbox to run your code -- but now you're using
the Click event of the tbClientName control to run the code. What is the
tbClientName control and what relationship does it have with the list box?
--

Ken Snell
<MS ACCESS MVP>





Bob V said:
Sorry Ken the {{ }} was to show you what was blued out!! Oops thanks Bob

Ken Snell (MVP) said:
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

should be

stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value

--

Ken Snell
<MS ACCESS MVP>



Bob V said:
Thanks Ken Brilliant :)
Works a treat!!
but how come when I do a Debug I get a compile error " Method or data
member not found , Below {{.ListNoClient}}
Private Sub tbClientName_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks Bob

End Sub
 
B

Bob V

Ken its called "Cross Contamination of an IDIOT" copied this code from
something else and must have changed that one as well , All Good now
Brilliant ;) Bob

Ken Snell (MVP) said:
OK - well, have you changed the name of the listbox control to
tbClientName? If not, if it's still named ListNoClient, then I'm not
understanding what you're doing in your code any more. Originally, you
were using the Click event of the ListNoClient listbox to run your code --
but now you're using the Click event of the tbClientName control to run
the code. What is the tbClientName control and what relationship does it
have with the list box?
--

Ken Snell
<MS ACCESS MVP>





Bob V said:
Sorry Ken the {{ }} was to show you what was blued out!! Oops thanks Bob

Ken Snell (MVP) said:
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

should be

stLinkCriteria = "[HorseID]=" & Me.ListNoClient.Value

--

Ken Snell
<MS ACCESS MVP>



Thanks Ken Brilliant :)
Works a treat!!
but how come when I do a Debug I get a compile error " Method or data
member not found , Below {{.ListNoClient}}
Private Sub tbClientName_Click()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmHorseInfo"
stLinkCriteria = "[HorseID]=" & Me{{.ListNoClient}}.value

DoCmd.OpenForm stDocName, , , stLinkCriteria
Thanks Bob

End Sub
 

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

Similar Threads


Top