By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,080 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,080 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

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

Expert Mod 15k+
P: 31,494
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
  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
  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.