Solved

ADO Control and MS Access

Posted on 2001-06-25
14
151 Views
Last Modified: 2013-11-23
I have a table called "Personal". Person_Id is one of the fields in the table.
The table is in ascending order by Personal_Id. When I used the MS Access to look at the table. The order is correct.

I have developed a vb form. All the textboxes are binding with ADO Control.
In vb form, the data are displayed in decending order. Why ?
How to make it displays in ascending order ?
0
Comment
Question by:johnmemor
14 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6225906
Hi, in your SQL in RecordSource, please use "Order By"


Such as:

Adodc1.RecordSource = "Select * from Personal Order By Person_id"

'Hope will help.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6225918
ryancys is correct. You need to use the ORDER BY clause to sort.

hongjun
0
 

Author Comment

by:johnmemor
ID: 6226058
Where should I put that recordsource ?
Because mt textboxes are binded to the ADO control.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6226071
Hu, You can set the RecordSource Property at run time:

Adodc1.RecordSource = "Select * from Personal Order By Person_id"
Adodc1.Refresh
0
 

Author Comment

by:johnmemor
ID: 6226094
I tried that code, still not correct.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6226106
Hi John, please kindly post your codes.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6226115
and remove the RecordSource 's Text from ADODC control, then try again.
0
 

Author Comment

by:johnmemor
ID: 6226141
The recordsource in the properties window is Personal. I have removed it, and
still not correct.

For example, if I have entered the following person_id in this order :

  120, 34, 344, 20

In the MS Access, you will see the person_id is in ascending order.
But in the vb form, it is 20, 344, 34,120
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6226152
What is the data type of person_id?
0
 

Author Comment

by:johnmemor
ID: 6226187
int
0
 
LVL 2

Expert Comment

by:mmcmillen
ID: 6226203
is there a index associated with that table?  Idont know much about the bound data control because I dont use it, but when you define the connection or database do you define the primary index for it?  

0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6226208
Hi, please check the Controls on how you bound in with ADODC control, as well as the SQL.

The "Order By" clause is definitely correct to sort your tables ascendingly.
0
 

Author Comment

by:johnmemor
ID: 6226309
no, I don't have index
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 35 total points
ID: 6226762
John, lets keep it simple(ish) at this stage. On the RecordSource tab of the properties dialog for the ADO Data Control. Set the CommandType to "1 - adCmdText" and in the Command Text (SQL) box place "Select * from Personal Order By Person_id ASC". This should then return the data correctly ordered for you. Of course you can do some or all of this through code assignement as well however to get you started it may be easiest to use the control in this way.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question