Error 2001 problem with OpenArgs and filter

supa_sumo

Registered User.
Local time
Today, 10:23
Joined
Jul 1, 2004
Messages
48
Ok heres the situation, Ive had to edit a piece of code that worked fine filtering but wouldnt allow me to refresh a subform on the main search form. Now im using OpenArgs to pass the Selected bike ID to a popup form. This bike ID should then be used to filter the pop up form. But i get error 2001 (You cancelled the previous operation) when the code is run.
The Code follows:

Private Sub cmdSell_Click()

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "frmSubSell"


DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog, Me.frmSubBikes!BikeID

Me!frmSubBikes.Form.Requery




Private Sub Form_Open(Cancel As Integer)
Dim SearchStr2 As String
SearchStr2 = "[BikeID]= " & Chr$(34) & Me.OpenArgs & Chr$(34)
Me.Filter = SearchStr2
Me.FilterOn = True

End Sub



Thanks, Sci
 
It looks to me like your BikeID is on a SubForm of the form that is calling the "frmSubSell" form. The reference is slightly different to get to the control:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog, Me.frmSubBikes.Form.BikeID
 
I tried that, well i tested that the openargs part worked by putting it into a textbox worked no problem. When i press debug when the error comes up it highlights (Me.FilterOn = True) I doesnt make sence really :(
 
Why are you using OpenArgs instead of just putting your WhereCondition in the stLinkCriteria argument?
 
Yer i didnt think of that for some reason. Works like a charm now. Thanks for all your help.
Code:
Private Sub cmdSell_Click()
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stDocName = "frmSubSell"
    stLinkCriteria = "[BikeID] = " & Forms![frmSearch]![frmSubBikes].Form![BikeID]
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
    Me!frmSubBikes.Form.Requery
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom