Solved

ADO Control and MS Access

Posted on 2001-06-25
14
147 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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
ryancys is correct. You need to use the ORDER BY clause to sort.

hongjun
0
 

Author Comment

by:johnmemor
Comment Utility
Where should I put that recordsource ?
Because mt textboxes are binded to the ADO control.
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
I tried that code, still not correct.
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi John, please kindly post your codes.
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
and remove the RecordSource 's Text from ADODC control, then try again.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:johnmemor
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
What is the data type of person_id?
0
 

Author Comment

by:johnmemor
Comment Utility
int
0
 
LVL 2

Expert Comment

by:mmcmillen
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
no, I don't have index
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 35 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now