Run-Time Error 2501 The OpenForm action was cancelled

Ula

Joined
Apr 9, 2016
Messages
2
Reaction score
0
I'm very new to VBA coding
I made a search form in which the information in the listbox should open up a form on double click

however, when i do it asks me to enter a parameter value and when i cancel it gives me a 2501 error

here's the code:

Private Sub List1_DblClick(Cancel As Integer)

Dim RowNumber As Integer
RowNumber = Me.List1.ListIndex + 1

Dim varCode, varTitle, varArtist, varLocation, varPrice, varType
varCode = (List1.Column(0, RowNumber))
varTitle = (List1.Column(1, RowNumber))
varArtist = (List1.Column(2, RowNumber))
varLocation = (List1.Column(3, RowNumber))
varPrice = (List1.Column(4, RowNumber))
varType = (List1.Column(5, RowNumber))

Dim Response As Integer
Response = MsgBox("Product Details" & vbCrLf & _
"------" & vbCrLf & _
"CD Code: " & varCode & vbCrLf & _
"Title: " & varTitle & vbCrLf & _
"Artist: " & varArtist & vbCrLf & _
"Location in Store: " & varLocation & vbCrLf & _
"Sale Price: " & varPrice & vbCrLf & _
"Type of Product: " & varType & vbCrLf & _
"For more information, click OK", vbOKCancel, "SearchResults")

If Response = vbOK Then
DoCmd.OpenForm "SearchResults", , , "[CDCode] = " & List1.Column(0)
Forms![SearchResults].CDCode.BorderColor = vbRed
Forms![SearchResults].CDCode.Enabled = False
Forms![SearchResults].CDCode.Locked = True

Else

End If





Thank you in advance :)
 
Back
Top