Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FILTER Question

Status
Not open for further replies.

ramrags

IS-IT--Management
Aug 17, 2001
62
US
I'm tring to open a form filtered by the selection
of a combo box, this is the code used in the after update event

Dim frm As Form
Dim Criteria As String

If Not IsNull(Me!cmbSelectEmp) Then
DoCmd.OpenForm "frmEmployee"
Set frm = Forms!frmEmployee
Criteria = ("EMP_NUM = '" & Me!cmbSelectEmp.Column(1) & "'")
frm.Filter = Criteria
frm.FilterOn = True
End If

End Sub
when i run this I get this error
Run-Time Error '2001'
You canceled the previous operation.
anybody have any ideas? thanks for any help
 
Hi,

An easier method to open the form to a particular record would be this:

Dim stDocName, stLinkCriteria, LinkVal

LinkVal = Me!cmbSelectEmp.Column(1)
stDocName = "frmEmployee"

stLinkCriteria = "[EMP_NUM]=" & "'" & LinkVal & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
I tried this the way you gave it to me, and now it comes back with a new error. Run-time error '2501'
The OpenForm action was canceled.

When i debug all the values are correct I dont understand why I get the error.
Any more thoughts. Thanks
 
Hmmmm... What version of Access are you using?

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
I'm using Access 2000, I checked all the forms properties and every thing looks fine
this really has me stumped. Thanks.
 
Hi,

I think the problem is with the criteria. Try this instead:

stLinkCriteria = "[EMP_NUM]=" & Me!cmbSelectEmp.Column(1)

- just comment out the linkval, and make sure that you are passing the right value to the linkcriteria or it won't work!

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Thats what it was... works just the way I wanted it to, now I can stop hitting my head on the wall. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top