By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Search from listbox

P: 1
Hi folks, and congratulations on your forum.

I have a problem when using a List Box to search a DB. The query below populates my list box using a search criteria, this works fine.
Expand|Select|Wrap|Line Numbers
  1. SELECT Clientes.Cliente, Clientes.Molde, Clientes.Estanterķa, Clientes.Fecha, Clientes.Orden FROM Clientes WHERE (((Clientes.Cliente) Like ([Forms]![BUSCAR_FRM]![txtSearchString])+"*"))
  2. ORDER BY Clientes.Cliente;
The problem is that when I double click the record desired it goes to the first record of the recordset for that client instead of going to the actual record. The keyID field in the table is "Orden" (which displays on the ListBox on the 5th column). Check code below.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ListaCliente_DblClick(Cancel As Integer) On Error GoTo Err_ListaCliente_DblClick
  3. Dim stDocName As String
  4. Dim stLinkCriteria As String
  6.     stDocName = "Clientes"
  7.     stLinkCriteria = "[Cliente]=" & "'" & Me![ListaCliente] & "'"
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9. Exit_ListaCliente_DblClick:
  10. Exit Sub
  12. Err_ListaCliente_DblClick:
  13. MsgBox Err.Description
  14. Resume Exit_ListaCliente_DblClick
  15. End Sub
I have limited knowledge of VB and would appreciate any help.

Thanks Clive
Jun 8 '06 #1
Share this Question
Share on Google+
2 Replies

P: 1
Hi there. Don't know if you are the same Clive Ellul who used to live in North London and pal about with Eric there. If so, you may remember me, Moray (Scottish bloke) from way back in the day (way back!). If not, sorry to have troubled you!!!
May 8 '09 #2

Expert 5K+
P: 8,638
@Clive Ellul
Try, assuming [Orden] is Numeric:
Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String 
  2. Dim stLinkCriteria As String 
  4. stDocName = "Clientes" 
  6. stLinkCriteria = "[Orden]=" & Me![ListaCliente].Column(4) 
  8. DoCmd.OpenForm stDocName, , , stLinkCriteria
May 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.