A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sorting records in a sub-form



 
 
Thread Tools Display Modes
  #1  
Old January 4th, 2009, 12:08 PM posted to microsoft.public.access.tablesdbdesign
john s
external usenet poster
 
Posts: 50
Default Sorting records in a sub-form

Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have taken-up
all the suggestions made and the db works well with one ‘People’ table and a
‘Status’ field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

“Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub”

I get an error message saying that the “command or action ‘sort ascending’
isn’t available now”. I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do this.

Regards,
John.
  #2  
Old January 4th, 2009, 01:09 PM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Sorting records in a sub-form

Set the OrderBy property of the subform, e.g.:

With Me.Volunteers.Form
.OrderBy = "SomeField"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S" wrote in message
...
Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have taken-up
all the suggestions made and the db works well with one ‘People’ table and
a
‘Status’ field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

“Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub”

I get an error message saying that the “command or action ‘sort ascending’
isn’t available now”. I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do this.

Regards,
John.


  #3  
Old January 4th, 2009, 01:57 PM posted to microsoft.public.access.tablesdbdesign
john s
external usenet poster
 
Posts: 50
Default Sorting records in a sub-form

Allen,

Many thanks - this seems to work...

BUT - not for a ComboBox on the sub-form?

The ComboBox is called "Name" and is made up of Surname & FirstName.

John.


"Allen Browne" wrote:

Set the OrderBy property of the subform, e.g.:

With Me.Volunteers.Form
.OrderBy = "SomeField"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S" wrote in message
...
Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have taken-up
all the suggestions made and the db works well with one ‘People’ table and
a
‘Status’ field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

“Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub”

I get an error message saying that the “command or action ‘sort ascending’
isn’t available now”. I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do this.

Regards,
John.



  #4  
Old January 4th, 2009, 03:17 PM posted to microsoft.public.access.tablesdbdesign
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Sorting records in a sub-form

Try renaming the combo box. Name is a reserved word, and using reserved
words for your own objects can lead to issues.

Allen's actually got a great list of names to avoid (and a link to a free
utility to check your application for compliance) at
http://www.allenbrowne.com/Ap****ueBadWord.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John S" wrote in message
news
Allen,

Many thanks - this seems to work...

BUT - not for a ComboBox on the sub-form?

The ComboBox is called "Name" and is made up of Surname & FirstName.

John.


"Allen Browne" wrote:

Set the OrderBy property of the subform, e.g.:

With Me.Volunteers.Form
.OrderBy = "SomeField"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S" wrote in message
...
Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have
taken-up
all the suggestions made and the db works well with one 'People' table
and
a
'Status' field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

"Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub"

I get an error message saying that the "command or action 'sort
ascending'
isn't available now". I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do
this.

Regards,
John.





  #5  
Old January 5th, 2009, 11:07 AM posted to microsoft.public.access.tablesdbdesign
john s
external usenet poster
 
Posts: 50
Default Sorting records in a sub-form

Doug:

Thanks for the link, its very helpful.

I had already tried renaming. Whatever name I use I get the "Enter Perameter
Value" prompt when the button is clicked.

Is this because of the Row Source of the Combo Box? Which is:
SELECT Personnel.PersonnelID, [Surname] & ", " & [Firstname] AS Expr1,
Personnel.Surname, Personnel.FirstName, * FROM Personnel ORDER BY
Personnel.Surname, Personnel.FirstName;

Regards,
John.

"Douglas J. Steele" wrote:

Try renaming the combo box. Name is a reserved word, and using reserved
words for your own objects can lead to issues.

Allen's actually got a great list of names to avoid (and a link to a free
utility to check your application for compliance) at
http://www.allenbrowne.com/Ap****ueBadWord.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John S" wrote in message
news
Allen,

Many thanks - this seems to work...

BUT - not for a ComboBox on the sub-form?

The ComboBox is called "Name" and is made up of Surname & FirstName.

John.


"Allen Browne" wrote:

Set the OrderBy property of the subform, e.g.:

With Me.Volunteers.Form
.OrderBy = "SomeField"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S" wrote in message
...
Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have
taken-up
all the suggestions made and the db works well with one 'People' table
and
a
'Status' field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

"Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub"

I get an error message saying that the "command or action 'sort
ascending'
isn't available now". I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do
this.

Regards,
John.





  #6  
Old January 7th, 2009, 12:40 AM posted to microsoft.public.access.tablesdbdesign
boblarson
external usenet poster
 
Posts: 886
Default Sorting records in a sub-form

To change the sort order of a combo box you will need to modify the RowSource
query and then reassign it.
--
Bob Larson
Free MS Access Tutorials and Samples at http://www.btabdevelopment.com

__________________________________


"John S" wrote:

Doug:

Thanks for the link, its very helpful.

I had already tried renaming. Whatever name I use I get the "Enter Perameter
Value" prompt when the button is clicked.

Is this because of the Row Source of the Combo Box? Which is:
SELECT Personnel.PersonnelID, [Surname] & ", " & [Firstname] AS Expr1,
Personnel.Surname, Personnel.FirstName, * FROM Personnel ORDER BY
Personnel.Surname, Personnel.FirstName;

Regards,
John.

"Douglas J. Steele" wrote:

Try renaming the combo box. Name is a reserved word, and using reserved
words for your own objects can lead to issues.

Allen's actually got a great list of names to avoid (and a link to a free
utility to check your application for compliance) at
http://www.allenbrowne.com/Ap****ueBadWord.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John S" wrote in message
news
Allen,

Many thanks - this seems to work...

BUT - not for a ComboBox on the sub-form?

The ComboBox is called "Name" and is made up of Surname & FirstName.

John.


"Allen Browne" wrote:

Set the OrderBy property of the subform, e.g.:

With Me.Volunteers.Form
.OrderBy = "SomeField"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John S" wrote in message
...
Hi,

Thanks to Clifford, Armen and Geoff for the recent advice. I have
taken-up
all the suggestions made and the db works well with one 'People' table
and
a
'Status' field.

I have come across another teething problem. I want to sort records in
ascending order by a certain field on a subform when the user clicks a
Command button on the main form.

I have set the Command button to run the following code:

"Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!Events!Volunteers.Form!Name.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 1, 0, acMenuVer70

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub"

I get an error message saying that the "command or action 'sort
ascending'
isn't available now". I believe this is because the command button has
retained the focus.

I should be grateful if anyone can advise me of a better way to do
this.

Regards,
John.





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.