Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2005, 04:16 PM
Authorized User
 
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sorting in a subform

I have a main form (frmProjects) , a subform (subfrmSites), and a subform within subfrmSites (subfrmProveniences). SubfrmProveniences has two number fields, txtProv_Horiz and txtProv_Vert, neither of which are a primary or foreign key.

I would like to sort subfrmProveniences by txtProv_Horiz then txtProv_Vert in that order, but whenever I change to the next project or site, the sort code that I put into subfrmProveniences no longer works. The code is:

Private Sub Form_Load()
Me.OrderByOn = True
Me.OrderBy = "intProv_Horiz, intProv_Vert"

End Sub

I'm sure that I need to do something to the On Current events for both frmProjects and subfrmSites, and have tried putting the following code into both forms:

Private Sub Form_Current()
Forms!frmProjects!subfrmSites!subfrmProveniences.O rderByOn = True
Forms!frmProjects!subfrmSites!subfrmProveniences.O rderBy = "intProv_Horiz, intProv_Vert"

End Sub


However, I keep getting error 438, saying I can't reference the subform in this manner.

How to I get subfrmProveniences to sort correctly?

Thanks for your help in advance

Bridog39

 
Old November 25th, 2005, 04:00 PM
Authorized User
 
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I fixed the problem! For all programmers who experience similar problems, the proper code to sort fields in the subform is:

Private Sub Form_Current()
Forms!frmProjects!subfrmSites!subfrmProveniences.F orm.OrderBy = "intProv_Horiz, intProv_Vert"
Forms!frmProjects!subfrmSites!subfrmProveniences.F orm.OrderByOn = True


End Sub

I didn't have the .Form before the OrderBy property, giving me the error.

Bridog39

 
Old November 27th, 2005, 01:06 AM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default

you could have also just edited the sort order of the queries the subforms were based on.






Similar Threads
Thread Thread Starter Forum Replies Last Post
subform jeremy1048 Access 0 May 2nd, 2008 09:03 AM
Requery SubForm lizhaskin Access 1 November 28th, 2005 02:19 PM
Subform on many to many data aware Access 14 August 12th, 2005 02:36 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
Filter Subform B Based on Field in Subform A SerranoG Access VBA 3 June 18th, 2004 12:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.