Run Time Error 2051

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
 
D

Dirk Goldgar

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?
 

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