473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to sort a subform table via VBA?

176 100+
Hello.

I have a subform which source is a table. The table, when displayed, gets sorted by an order which is not the order I set for that table in it's design view. Is there any way to get that table displayed by an order of my preference?

Thanks.
Nov 27 '06 #1
8 7584
Create Query instead of basing it on the Table and then put the sort in the Query.

Hope that helps,
Cz.
Nov 27 '06 #2
PEB
1,418 Expert 1GB
U can change the recordsource property of the subform using VBA

IThe reference of your subform depends where is placed your code! Where do you want to place it? In subform, in the main form or in a module?
Nov 27 '06 #3
Michael R
176 100+
Create Query instead of basing it on the Table and then put the sort in the Query.
Thanks for the reply, I can't do that, because I need the subform to be able to open child table.

U can change the recordsource property of the subform using VBA

IThe reference of your subform depends where is placed your code! Where do you want to place it? In subform, in the main form or in a module?
I want to place the code in the form, as i'm not understand the other possibilities you've mentioned. I just need the subform to be sorted when I open the form, and the subform is a control in a form.

What would you recomend me to do?

Thanks.
Nov 27 '06 #4
PEB
1,418 Expert 1GB
As u describe it seems to me that you don't need to do different sorting from the initial one?

In this case i think u don't need to do any code! Simply create your query on which is based your subform and assign under the respective columns on which you want to sort the respective sort order. Once created your query go to the properties in your subform and assign this query as row source of your subform!

If u don't use a query as row source for your subform, this is no problem to get the respective table in a query and assign the sorting order to the wanted columns! Then assign the created query to Row source of your subform!

If you need to change the sorting during the work of your form in this case you need a code and this code will change just this row source property assigning the new query values!
Nov 27 '06 #5
Michael R
176 100+
As u describe it seems to me that you don't need to do different sorting from the initial one?

In this case i think u don't need to do any code! Simply create your query on which is based your subform and assign under the respective columns on which you want to sort the respective sort order. Once created your query go to the properties in your subform and assign this query as row source of your subform!

If u don't use a query as row source for your subform, this is no problem to get the respective table in a query and assign the sorting order to the wanted columns! Then assign the created query to Row source of your subform!

If you need to change the sorting during the work of your form in this case you need a code and this code will change just this row source property assigning the new query values!
The subform automatically gets sorted by the index field of the table it uses, in spite of me changing the table sort order from its design view.

I can't use query for that table, because I need the subform table to be able to open child tables.
Nov 27 '06 #6
PEB
1,418 Expert 1GB
The subform automatically gets sorted by the index field of the table it uses, in spite of me changing the table sort order from its design view.
With query it will be solved... Changes in design view think can't help you!

I can't use query for that table, because I need the subform table to be able to open child tables.
I don't see where is the problem here? The query will have a behaviour just like a table if you do SELECT * FROM mytable ORDER BY A, B;

What is this child tables?
Nov 27 '06 #7
NeoPa
32,556 Expert Mod 16PB
There is an Order By property in forms.
The order of the underlying dataset won't matter.
Nov 27 '06 #8
PEB
1,418 Expert 1GB
There is an Order By property in forms.
The order of the underlying dataset won't matter.
Yeap this is also possibility

Cheers Ade u've the fastest thousnd my frin :)
Nov 27 '06 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: xah | last post by:
i'm just starting out on javascript. can anyone show me how to go about writing a code to sort a table column? something like the following: <table border="1"> <tr> <td>
4
by: alex_peri | last post by:
Hello, I am looking for a good way to permanently sort a table in Access. The way i have below works but i was wondering if there is a better and faster way. Kind regards, Alex ...
6
by: cygsoft | last post by:
I hava a combobox. in that contain date,subject,sender. How to sort date,sender and subject while using combox in inbox
5
by: Nirmala123 | last post by:
hi... I want to sort the table using combobox values. I give the code here. address.html: <html> <head> <title>Add a new entry</title> </head>
3
by: RamiH | last post by:
Hi, I am using a listbox to show data from a certain table, i want the user, after the listbox is filled, to be able to sort the data according to the column of his choice. I could sort the table...
2
by: bcarson86 | last post by:
Hi, I am trying to append a list of part numbers which is generated in a seperate table into a subform table which is on a main form. My main problem with getting it to work is that I need the part...
3
wordbrew
by: wordbrew | last post by:
I'm nearly done with a database but there is one more thing I would like to add. I would like to add add a combo box, let's say I call it , to my form , where the contents of the combo box are...
4
by: Ploepsie | last post by:
Hey, first of all I want to state that I am very new to using Access and therefor the question might be relevantly easy to solve but I have spent hours thus far to find the answer online and in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.