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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by or filter on form / subform.

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello I am trying to get the following code to work:

Private Sub Command14_DblClick(Cancel As Integer)
Me.OrderBy = "[property address (1)] ASC,[property no] ASC"
Where ([Property No] = 28)
Me.OrderByOn = True
End Sub

The code works without the Where line.

Basically I want to sort the property by address, but only when the property number is 28

Can someone point me in the right direction and is there something else I should have in my code should
there be no records?

Many thanks Mark
 
Ok i have tried this code and it works - yipeeeee

Are any additions required (I am just learning code)

Thanks

Mark

Private Sub Command14_DblClick(Cancel As Integer)

Me.FILTER = "property number = 28"
Me.FilterOn = True
Me.OrderBy = "[property address (1)] ASC,[property no] ASC"
Me.OrderByOn = True

End Sub
 
Scrap that -

This doesnt work,

Private Sub Command14_DblClick(Cancel As Integer)

Me.FILTER = "property number = 28"
Me.FilterOn = True
Me.OrderBy = "[property address (1)] ASC,[property no] ASC"
Me.OrderByOn = True

End Sub

But this does:

Private Sub Command14_DblClick(Cancel As Integer)

Me.FILTER = "deposit = 500"
Me.FilterOn = True
Me.OrderBy = "[property address (1)] ASC,[property no] ASC"
Me.OrderByOn = True

End Sub


The only differnce I can see is that the first refers to a text field and the second to a currency field????

Thanks Mark




 
Code:
Me.FILTER = "property number = 28"
One issue is the name of the field containing a space. Wrap the field name with []s like your other code.

If [Property Number] is a text field, you will need to use:
Code:
Me.FILTER = "[COLOR=#EF2929][[/color]property number[COLOR=#EF2929]][/color] = [COLOR=#EF2929]'[/color]28[COLOR=#EF2929]'[/color]"


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top