By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Basic Query help

P: 2
Hi, I'm a novice at this so maybe someone can point me in the right direction. I have several tables in a database, one being the main table, and want to query one column in each table back the main one.

Structure is

Field1 | Field 2
Text | Number
Text | Number
Text | Number

So the query I want to perform is, if the number is higher in Field 2 in the other tables than the main table, it needs to report Text | Number (from other table) | Number (from main table) | Table name

I hope I have explained it well enough.

Thanks :)
Mar 2 '07 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,316
I'm thinking a nested iif statement. How many tables are there?
Mar 2 '07 #2

NeoPa
Expert Mod 15k+
P: 31,186
This may well get very complex if there are several tables.
In a situation like this you may prefer to create a new module (or incorporate this into an existing one if you prefer) containing the following code :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. 'HighVal returns the highest value of its parameters.
  5. Public Function HighVal(varFirst As Variant, _
  6.                         ParamArray avarParms() As Variant) As Variant
  7.   Dim intIdx As Integer
  8.  
  9.   HighVal = varFirst
  10.   For intIdx = LBound(avarParms) To UBound(avarParms)
  11.     If avarParms(intIdx) > HighVal Then HighVal = avarParms(intIdx)
  12.   Next intIdx
  13. End Function
Mar 3 '07 #3

Post your reply

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