Run-Time Error '2501'

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I get a run-time error when I run this code. When I do the debug it appears
that its finding the data. Its failing on the DoCmd.

I don't know why this isn't working. I have used this same type of code
before to open a form and find the specific item.


Private Sub QuoteID_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLink As String
Dim SID As String

stDocName = "frmQuotes"

SID = Me.quoteID.Value

stLink = "[QuoteID]=" & "'" & SID & "'"
DoCmd.OpenForm stDocName, acNormal, , stLink


End Sub
 
D

Dirk Goldgar

mattc66 via AccessMonster.com said:
I get a run-time error when I run this code. When I do the debug it
appears that its finding the data. Its failing on the DoCmd.

I don't know why this isn't working. I have used this same type of
code before to open a form and find the specific item.


Private Sub QuoteID_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLink As String
Dim SID As String

stDocName = "frmQuotes"

SID = Me.quoteID.Value

stLink = "[QuoteID]=" & "'" & SID & "'"
DoCmd.OpenForm stDocName, acNormal, , stLink


End Sub

Is QuoteID a numeric field, or text? If it's numeric, then you don't
need the quotes around SID, and it should be:

stLink = "[QuoteID]=" & SID

That might be the cause of the error, if the where-condition is invalid.
 

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

Top