Run Time Error 2051

  • Thread starter Thread starter Todd
  • Start date Start date
T

Todd

Howdy,

I'm trying to open a form that provides information
relating to an item in a list box. I'm using the
following (which I've used several time before):

Private Sub List5_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmTest", wherecondition:="Rqmt_ID = " &
Me.List5
End Sub

I keep getting Run Time Error 2051.

Any ideas?

Thanks, Todd
 
Todd said:
Howdy,

I'm trying to open a form that provides information
relating to an item in a list box. I'm using the
following (which I've used several time before):

Private Sub List5_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmTest", wherecondition:="Rqmt_ID = " &
Me.List5
End Sub

I keep getting Run Time Error 2051.

Any ideas?

Thanks, Todd

That error is an "action cancelled" message. Assuming you don't have
code in the Open event of frmTest that is cancelling the open, it's
likely that there's something in your WhereCondition that is causing a
syntax error in its evaluation. Is Rqmt_ID a text field, by any chance?
If so, you need quotes around the value from Me.List5; e.g.,

DoCmd.OpenForm "frmTest", _
wherecondition:="Rqmt_ID = '" & Me.List5 & "'"

If that's not it, is List5 a multiselect list box, in which case it has
no value? Or is the bound column of the list box Null for some reason?
 
Back
Top