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

Function used in SQL Select query

Hi all,

This problem has me dumbstruck at the moment and I was wondering if
someone could offer some advice while I have a go at it myself.

Background:
I have a query qryAll that takes data from numerous tables, and
produces the following data(Note: 1="Acme" and 2="Other" under column
Car1_Brand):

Name Car1_Brand Car1_Acme_Model Car1_Oth_Name Car1_Oth_Year
---- ---------- --------------- ------------ ---------
Smith 1 A123
Jones 2 Corvette 2000
Gates 1 A234
Dell 2 Mercedes 2004
So, if a person has "Acme" under Car1_Brand, then the next column
Car1_Acme_Model will give the model of the specific car made by Acme.
However, if she has other under Car1_Brand, then then name and year is
given in the last two columns.

What I have done so far is write a select query in my VB code which
uses a built-int function GetBrand to get the Car1_brand for each
person, in the following way:

strSelect = "SELECT GetBrand(Nz([qryAll.Car1_Brand])) AS CAR_1, "

NOTE: (GetBrand(integer) uses a simple Select Case to return a string
with the car type based on the integer supplied as parameter, 1="Acme"
and 2 ="Other")

Problem:
I want a column in my VB code's query for CAR_1_TYPE (i.e. something
with ...AS CAR_1_TYPE...). This column will look at the Car1_Brand
of each person, and when it is "Acme", it will display Car1_Acme_Model,
and when it is "Other", it will concatenate the two strings from
columns Car1_Oth_Name & Car1_Oth_Year. I wanted to write a simliar
function to GetBrand() above, but do not know how I should make it
always look at the current record, this is a bit confusing! So that my
VB code will look like this:

strSelect = strSelect & GetModel(Nz([qryAll.Car1_Acme_Model]),
Nz([Car1_Oth_Name]),
Nz(Nz([qryAll.Car1_Acme_Model]))

TIA

Nov 13 '05 #1
0 1314

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
6
by: Christian | last post by:
HI, I have a function that is used to constrain a query: Select COl1, Col2 From MyTable WHERE col1 = ... AND col2 = ... And MyFunction(col1) = ... My problem is that MyFunction is executed...
2
by: Pink Panther | last post by:
Using the following SQL can the results be explained? Using A97 (with the SP2 for Jet 3.5) or A2002 CREATE TABLE Test (PK Number CONSTRAINT PK_TEST PRIMARY KEY, ParentID Number, Child...
0
by: Reggie | last post by:
Hi and TIA, I Have a query that uses a function for setting the Criteria. When I view the return value of the finction it appears to be exactly what I want for my criteria. The problem is if I...
3
by: Janross | last post by:
I'm having trouble with a query that's prohibitively slow. On my free-standing office computer it's fine (well, 2-4 seconds), but on the client's network, it takes at least 5 minutes to run. ...
1
by: Peter Alberer | last post by:
Hi there, i have a problem with a query that uses the result of a plsql function In the where clause: SELECT assignments.assignment_id, assignments.package_id AS package_id,...
4
by: uspensky | last post by:
I have a table (cars) with 3 fields: VIN, Class, sell_price 101, sports, 10000 102, sports, 11000 103, luxury, 9000 104, sports, 11000 105, sports, 11000 106, luxury, 5000 107, sports, 11000
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
5
by: dubing | last post by:
Hello everyone, There is a field of DATETIME type in our Access 2000 database. PHP is used to query the data and display the query results on the web. Does Access provide any function that can...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.