wilson1001
Registered User.
- Local time
- Today, 06:49
- Joined
- Mar 24, 2003
- Messages
- 17
Hello
I have created a form that accepts input via a text box( txtfilter) and command button (cmdsearch).
The inputed term is used to search all fields in my table (parts) and the results of the search are displayed in a list box (lstresults)
When a result in the list box is clicked on it should display the record on a new form.
My problem – When a result is clicked on I receive the following error and the form does not open.
Run-time error 2501
"The openform action was cancelled"
Can anyone tell me if I have messed up the syntax on my “Docmd.openform” ?
Thanks
Pete
My code:
Private Sub cmdSearch_Click()
If IsNull(Me.txtfilter) Then
MsgBox "You have not entered any text.", vbExclamation, "Attention"
Exit Sub
End If
With LSTRESULTS
.RowSource = "Select * FROM parts WHERE ((([part no]) Like '*" & Me.txtfilter & "*') OR (([description]) Like '*" & Me.txtfilter & "*') OR (([bin location]) Like '*" & Me.txtfilter & "*')OR (([in stock]) Like '*" & Me.txtfilter & "*')OR (([price 1]) Like '*" & Me.txtfilter & "*')OR (([price 2]) Like '*" & Me.txtfilter & "*')OR (([price 3]) Like '*" & Me.txtfilter & "*') );"
.Requery
End With
End Sub
Private Sub Command54_Click()
End Sub
Private Sub Form_AfterUpdate()
End Sub
Private Sub lstResults_AfterUpdate()
DoCmd.OpenForm "parts", acNormal, , "[part no] = " & LSTRESULTS.Column(0)
End Sub
Private Sub Close_search_form_Click()
On Error GoTo Err_Close_search_form_Click
DoCmd.close
Exit_Close_search_form_Click:
Exit Sub
Err_Close_search_form_Click:
MsgBox Err.Description
Resume Exit_Close_search_form_Click
End Sub
Private Sub List70_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[part no] = " & Str(Nz(Me![List70], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
I have created a form that accepts input via a text box( txtfilter) and command button (cmdsearch).
The inputed term is used to search all fields in my table (parts) and the results of the search are displayed in a list box (lstresults)
When a result in the list box is clicked on it should display the record on a new form.
My problem – When a result is clicked on I receive the following error and the form does not open.
Run-time error 2501
"The openform action was cancelled"
Can anyone tell me if I have messed up the syntax on my “Docmd.openform” ?
Thanks
Pete
My code:
Private Sub cmdSearch_Click()
If IsNull(Me.txtfilter) Then
MsgBox "You have not entered any text.", vbExclamation, "Attention"
Exit Sub
End If
With LSTRESULTS
.RowSource = "Select * FROM parts WHERE ((([part no]) Like '*" & Me.txtfilter & "*') OR (([description]) Like '*" & Me.txtfilter & "*') OR (([bin location]) Like '*" & Me.txtfilter & "*')OR (([in stock]) Like '*" & Me.txtfilter & "*')OR (([price 1]) Like '*" & Me.txtfilter & "*')OR (([price 2]) Like '*" & Me.txtfilter & "*')OR (([price 3]) Like '*" & Me.txtfilter & "*') );"
.Requery
End With
End Sub
Private Sub Command54_Click()
End Sub
Private Sub Form_AfterUpdate()
End Sub
Private Sub lstResults_AfterUpdate()
DoCmd.OpenForm "parts", acNormal, , "[part no] = " & LSTRESULTS.Column(0)
End Sub
Private Sub Close_search_form_Click()
On Error GoTo Err_Close_search_form_Click
DoCmd.close
Exit_Close_search_form_Click:
Exit Sub
Err_Close_search_form_Click:
MsgBox Err.Description
Resume Exit_Close_search_form_Click
End Sub
Private Sub List70_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[part no] = " & Str(Nz(Me![List70], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub