473,425 Members | 1,747 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,425 software developers and data experts.

Pass Through Query Nightmare (Access 2K --> SQL Server 2000)

Hello again, I'm still in the process of changing ms access queries to
Pass through queries. We're using a SQL Server 2000 database with an
Access 2000 DB as our front end.

I trying to convert this ms access query to a pass through and I'm
having quite a hard time doing it, so I hope you guys can help me. I
have a clients form and in this form there are 2 combo boxes where a
user can select a client's Type and Status. One for each. However, if
they don't need to choose anything, that field should be Null. Here's
the access query:

SELECT tblClients.Number, tblClients.Type
FROM tblClients
WHERE (((tblClients.Type)=[Forms]![frmClients]![CLType])
AND
((IIf(IsNull([Forms]![frmClients]![CLStatus]),((([tblClients].[Status])
Is
Null)),((([tblClients].[Status])=[Forms]![frmClients]![CLstatus]))))<>False))

OR
(((IIf(IsNull([Forms]![frmClients]![CLStatus]),((([tblClients].[Status])
Is
Null)),((([tblClients].[Status])=[Forms]![frmClients]![CLstatus]))))<>False)
AND (([Forms]![frmClients]![CLtype]) Is Null))

The IIF part in the criteria AND and OR is the same. Since I have to
check the value of the boxes first and the IS Null part cannot be equal
to False, I'm stuck. I know I can't use the boxes values all the way
through because SQL 2000 will not understand them, so I guess I have to
come up with something first before activating the pass through query.
Any help would be extremely appreciated.

Thanks.

JR.

Dec 6 '05 #1
2 2880
I think this has been explained to you previously by someone more
familiar with passthrough queries than I, but here's the bottom line
(assuming I'm right; someone will tell us if not);
1. A PassThrough query must be written in the dialect of the database
server to which it is being passed, in this case in the Transact-SQL
[T-SQL] dialect of MS-SQL;
2. The PTQ must be a pure string; T-SQL will know absolutely nothing
about your Forms or Access; you may get away with something like "WHERE
Sex = " & txtSex.Value & "blah blah" but you will not get away with
"WHERE Sex = txtSex.Value".
3. If I had to do this thing I would put in the form's module a sub or
function that created that string, accounting for whatever values might
appear in boxes, (including no values at all, or nulls) and I would
debug.print the string. Then I would test it in the MS-SQL DB. Then I
would write code to test it before I sent it; When I got it right, I'd
use it.

Dec 6 '05 #2
Hello Lyle. I just found the solution and in a way it's what you're
saying. I'm first checking the value of the boxes and according to
them, I build the SQL string. I'm using a Select Case statement where
it checks whether the Status is Null, If it is Null then I check
whether the Type is Null, or else and then I do the same when the
Status is Else.

After I checked both values the appropiate SQL string is sent to the
SQL server and I get what I need.

Thanks for your input. I greatly appreciate it.

JR.
Lyle Fairfield wrote:
I think this has been explained to you previously by someone more
familiar with passthrough queries than I, but here's the bottom line
(assuming I'm right; someone will tell us if not);
1. A PassThrough query must be written in the dialect of the database
server to which it is being passed, in this case in the Transact-SQL
[T-SQL] dialect of MS-SQL;
2. The PTQ must be a pure string; T-SQL will know absolutely nothing
about your Forms or Access; you may get away with something like "WHERE
Sex = " & txtSex.Value & "blah blah" but you will not get away with
"WHERE Sex = txtSex.Value".
3. If I had to do this thing I would put in the form's module a sub or
function that created that string, accounting for whatever values might
appear in boxes, (including no values at all, or nulls) and I would
debug.print the string. Then I would test it in the MS-SQL DB. Then I
would write code to test it before I sent it; When I got it right, I'd
use it.


Dec 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amy Tseng | last post by:
Hi, I am having a problem accessing SQL Server 2000 via UNIX. I am accessing SQL Server 2000 from Solaris using Sybase Open Client (CT-Lib). Here is the error message: CT-LIBRARY error:...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
1
by: sylmart7 | last post by:
I am trying to run xp_cmdshell from the Query Analyzer using SQL Server 2000 running on Windows 98. It seems like it should be simple - I'm typing xp_cmdshell 'dir *.exe' in the Query...
1
by: Andrew | last post by:
I have a relatively simple SQL Server 2000 database which I am querying from a VB.NET application. The query is very simple, such as SELECT * FROM tblSystems. Let's say there are 10 records in...
1
by: Stefan V. | last post by:
Hello! I am trying to convert a query written for SQL Server 2000 database tables, to a MS Access query. Here is what I have in SQL Server: SELECT t2.*, CASE WHEN t2.QType = '3' THEN...
3
by: ILCSP | last post by:
Hello, I'm fairly new to the concept of running action pass through queries (insert, update, etc.) from Access 2000. I have a SQL Server 2000 database and I'm using a Access 2K database as my...
2
by: ILCSP | last post by:
Hello, I'm in the process of changing our 'normal' Access 2000 update queries to Update Pass Through Queries. We have a SQL server 2000 database and we're using an Access 2000 database as our...
0
by: Stanley Sin | last post by:
Dear all , How can I remote access SQL server 2000 using vb.net? I don't know how to use ADO.net to remote access database . Any solutions? Thanks in advance. Stanley
0
by: vdrane | last post by:
my sql server 2000 is running on microsoft server 2003.i want to access the database from my unix/aix operating system.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.