[mso] Re: Access Select Query

  • From: "Jim Pettit" <jimpettit@xxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Fri, 25 Mar 2005 13:03:12 -0800

Glenda--

Sorry it took me so long to get back with you. Now, do you mean you'd like
to see how to create a query, one which uses the ANSI SQL IN and/or LIKE
operators, in VBA? Please let me know, and I'll be happy to do so.

If PT queries won't work -- and they certainly don't always -- you certainly
can make your Access queries on the fly. (And they can be saved for later
use, or destroyed as soon as you're through ith them.) Remember, though,
that Access will optimize a saved query, where as ad hoc queries need to be
built and optimized at run time, so there is definitely a performance hit. 

Something to remember, too, if you're using Access to pull from SQL Server
or Oracle, is that you can create a PT query to call a stored procedure that
is on the database server, and pass query parameters to that stored
procedure from within Access. If course, while we are talking about Access
here, the art and science of writing and using stored procedures is
definitely out of the realm of this newsgroup; I doubt Linda (or anyone
else) would be thrilled with us chatting about them here. ;-)

--Jim

-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf
Of Glenda Wells
Sent: Thursday, March 24, 2005 8:51 AM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: Access Select Query

It does help jim. Thanks.  I've determined that using pass-thru for my
purposes isn't going to work.  So I'm building select and make table
queries. Should I build them on the fly instead of storing them?  Do you
have a sample you'd be willing to share? I'm doing something I've never done
before and need this particular db/process to work quicly.

Right now I'm going to build 5 append queries, one each for the 4 values I
need and one to clear out the table in preparation for using it again.
I've developed processes this way before and it seems to run faster than
trying to get the 4 values in one query.  In this example, it takes 11
minutes to extract my data if I use the and & or rows of criteria.
Doing the append thing for each value shortens that time to about 90
seconds.  However, it would not be practical where there were dozens of
values to extract.

/g

-----Original Message-----
From: Jim Pettit [mailto:jimpettit@xxxxxxxxx]=20
Sent: Thursday, March 24, 2005 11:40 AM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: Access Select Query

Glenda--

As far as I know, Access makes no real distinction between the two (although
I may be wrong). I believe that when the Jet database engine parses the
query, it internally converts the two formats into the same thing
internally; that is, the DB engine makes a list of each of the values, then
compares each item in that list against the table or index.
FWIW, I usually use the IN("value1", "value2") construct, as I tend to build
a lot of queries on the fly from VBA code, and that allows me to, for
example, build shorter query strings, strings that are more readable when
debugging, and strings that can be imported/exported to/from Excel via the
CSV format.
Also, when using the IN, a subquery or series of nexted subqueries can be
placed within the parentheses. For instance:

SELECT vegetables FROM tblProduce WHERE type IN(SELECT type FROM tblTypes
WHERE type =3D 'cruciferous')

Hope this helps...

--Jim

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx
with the word "unsubscribe" (without the quotes) in the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: