Error 2501 - List Box

  • Thread starter Thread starter Chris_S
  • Start date Start date
C

Chris_S

Hello,

here's the problem:

There is a table with columns called Number
(Autoincrement) and ContractNo (text, 12 digits, only
numbers).

On the form there is a List Box that gets the rows from
the mentioned table and the mentioned colums but only
ContractNo is displyed.

Now,

on Listbox DoubleClick there is an action to open other
form locked on a record specified by the value of listbox

when column Number is bound (the hidden one) something
like this works perfect:
DoCmd.OpenForm "Form1_Frm", , , "Number=" & Me.List0.Value

but when the second column is bound (ContractNo) this
doesn't work and calls 2501 error:
DoCmd.OpenForm "Form1_Frm", , , "ContractNo=" &
Me.List0.Value

Where is my mistake?

Grateful for any hints on how to solve this problem?
 
You are not specifying the column.
Try
==============
DoCmd.OpenForm "Form1_Frm", , , "ContractNo=" &
Me.List0.Column(1)
==============
The column reference is zero based.
HTH
Terry
 
The second column is text and therefore must be delimited in your call with text
delimiters (quote marks or apostrophes). My preference for this is to use
Chr(34) which reads more clearly to me.

DoCmd.OpenForm "Form1_frm",
"ContractNo=" & Chr(34) & Me.List0.Value & Chr(34)

But you can do it
DoCmd.OpenForm "Form1_frm",
"ContractNo=""" & Me.List0.Value & """"

or
DoCmd.OpenForm "Form1_frm",
"ContractNo=" & Me.List0.Value & "'"
 
Back
Top