473,406 Members | 2,352 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,406 software developers and data experts.

Quick DoCmd.OpenQuery Question

153 100+
I should probably know this, but I have a query that I'm opening with VBA:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenQuery "SortTableClientCN_ASC", acViewNormal, acEdit
the query is the following:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblClientCN.ClientCN
  2. FROM tblClientCN
  3. ORDER BY tblClientCN.ClientCN;
I simply need to order this column in ascending or descending order (doesn't matter) - however I want to edit the actual table with the ordered results and was not sure if there was simple way to save the results of the query to the table?

I don't have any primary keys

Thanks!
Jan 21 '08 #1
7 2732
jaxjagfan
254 Expert 100+
I should probably know this, but I have a query that I'm opening with VBA:

DoCmd.OpenQuery "SortTableClientCN_ASC", acViewNormal, acEdit

the query is the following:

SELECT tblClientCN.ClientCN
FROM tblClientCN
ORDER BY tblClientCN.ClientCN;

I simply need to order this column in ascending or descending order (doesn't matter) - however I want to edit the actual table with the ordered results and was not sure if there was simple way to save the results of the query to the table?

I don't have any primary keys

Thanks!
For the most part records and entries are saved in the order they are entered. If we need ordered views for whatever reason that is normally accomplished with queries.

Is there a reason to reorder the table after making entries?
Jan 21 '08 #2
Kosmos
153 100+
Yes. I'm trying to find duplicate records and the number of times they occur...gotta go to a meeting but will be back. I guess I could just output to another table I'm trying to make this a bit more of a simplified process. Thx
Jan 21 '08 #3
jaxjagfan
254 Expert 100+
Yes. I'm trying to find duplicate records and the number of times they occur...gotta go to a meeting but will be back. I guess I could just output to another table I'm trying to make this a bit more of a simplified process. Thx
What is the table structure? What field or combination of fields are you looking to count?

"SortTableClientCN_ASC" is this an acsii file you are importing?

FYI - If you select "New Query" and choose "Find Duplicates", Access wizards will help you build a find dupes query as longs as the data is not too complex.

If the wizard can't help you out, give us some more details on the table and what you are trying to accomplish. I'm sure we can come up with a solution.
Jan 21 '08 #4
Kosmos
153 100+
Alright well I appreciate your help! Unfortunately, for this project, I have to be careful about what I post. Anyways...I have already found a solution to the original way I intended to handle this. As you may have seen from some of my earlier posts...I do like to post a lot of code so that I can give back to the community.

Here was my original problem which I tried to work around as I had thought that Access did not support it:

recSet1.Sort = "ClientCN ASC"

Problem:
In addition to opening my recordset in the usual way, I also had to add the following line of code:

recSet1.CursorLocation = adUseClient before my recSet1.open declaration

For further explanation on the root cause of this problem:
http://support.microsoft.com/kb/253248

Thx!
Jan 22 '08 #5
NeoPa
32,556 Expert Mod 16PB
I appreciate your attitude Kosmos. Feedback is always good.
I'd be grateful if you'd try to remember to use the code tags when posting code in future though. With over a hundred posts you should know the drill by now ;)

As to storing the data, you mention you don't have a Primary Key - well I would suggest from this request that indexes are exactly what you need. As Jax says, the order of the records physically in the table is undefined (generally the order entered but not reliably so I believe). If any order is required then it should be defined either by an index or by using a sorted query.

I hope this helps for future situations.
Jan 22 '08 #6
Kosmos
153 100+
Hey Neo,

thanks for the info...as always! I remember when I was just starting out in programming and you had less than 1000 posts because some error had reset everything but you're already at 7,000+ so yeah I'm glad to help out

anyways...I appreciate your advice about using primary keys but I tend to avoid using primary keys where possible as I use a lot of vb scripting that I will be able to remove from access sometime down the road...the intention is that some of the programming I'm doing here will be implemented outside of access sometime in the future

Anyways thanks again!
Feb 12 '08 #7
NeoPa
32,556 Expert Mod 16PB
That's a while back Kosmos :)

Just remember that unindexed data is pretty well random when retrieved in Access.
Feb 14 '08 #8

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

Similar topics

0
by: Jim | last post by:
I am using Access 97 on a PC running Windows NT 4.0 SP6a. I have some code (shown below) intended to add a set of records to one table (tblGradeProps) when a new record is created in another...
3
by: jj | last post by:
I've got a form button that fires off 3 queries but if the first query returns an error, I don't want the other two queries to happen. Example: first query runs an insert from a linked table but...
1
by: tina | last post by:
Hello, I would really appreciate some help. I am still learning VBA and I feel like my brain is fried already. Below I am trying to run a query and do a loop. I actually get the data set but...
2
by: technocraze | last post by:
Hi community experts, May I know is it possible to display an error message or not opening a form or query when users provide with the wrong inputs in the DoCmd.OpenForm and DoCmd.OpenQuery...
1
by: VBANewbie | last post by:
Hi all, Just a small question concerning the memory problem. Whenever we open an existing query inside a module: DoCmd.OpenQuery ("Query Name") Do we have to put another command line to...
10
by: teddysnips | last post by:
My clients have asked me to maintain a database that was developed in- house. It's pretty good, considering the developer isn't a "programmer". The first thing they want me to do is to split it...
10
by: Dean | last post by:
My client has a db I am working that uses temp tables. During an update procedure, I had the code If fTableExists(tempTblName) = True Then DoCmd.DeleteObject acTable, tempTblName Then I thought...
6
by: RZ15 | last post by:
Hi, I frequently have code in my forms that will turn warnings off, run make table queries, then turn warnings back on using the following code: DoCmd.SetWarnings WarningsOff DoCmd.OpenQuery...
4
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.