Using OrderBy gives error at reopening form.

naverty

Registered User.
Local time
Tomorrow, 00:06
Joined
Dec 1, 2004
Messages
10
I have a form where the recordsource is a stored procedure.

This forms shows a list. When the user clicks on a column title, the column is sorted by using OrderBy in VBA:

f.i.:

Private Sub lblCode_Click()

Me.OrderBy = "strCode"

End Sub

As a result, in the properties of the form, for the property Order By, the fieldname is filled in (f.i. strCode).

This works fine, but when the form is closed, access saves the property Order By.

Next time the form is opened, it gives an error: The recordsource <storedprocedurename> specified on this form does not exist.

When I remove the fieldname in the Order By property of the form, the form opens without an error.

I have tried to clear the Order By property by using Me.OrderBy = "" in the Close event of the form, but this does not work.

Any solution ?
 
try using:

Code:
Me.OrderBy = "strCode"
Me.OrderByOn = True
 
can you reset the orderby to blank in the froms close event
 

Users who are viewing this thread

Back
Top Bottom