How refer to a column in SQL ?

  • Thread starter Thread starter Guest
  • Start date Start date
I don't believe it's possible, but I have to confess I can't think of a
single time when it should be necessary to do that.

What are you trying to accomplish?
 
I have 2 combo boxes called RuleFrom and RuleTo.
A rule consists of 5 components; Title, Chapter, Article, Topic and SubTopic
Each combo box contains all components of the rule in separate columns.
My query has to select Rules based on the RuleFrom and RuleTo combo boxes
and it needs to compare each component individually to do this.

Yes, I could store the selected Rule components in hidden controls - which
is what i will do if I cannot refer to specific combo box columns in SQL.
 
In VB code, I use .Column(number) but how do I do it in SQL, it rejects that
syntax.

If you're trying to include a value from a form control (a combo or
listbox I presume) you must reference the entire form:

[Forms]![NameOfForm]![NameOfControl]

and I believe it only has access to the bound column.

John W. Vinson[MVP]
 
Sorry, I misread what you were trying to do.

I believe John is correct that you have no choice but to use hidden
controls: that through SQL, you only have access to the bound column in a
list box or combo box.
 
You could wrap the VBA code in a function and call the function in a query,
passing the column number into it as its argument:

Function GetColumn(intCol As Integer)

Dim ctrl As Control

Set ctrl = Forms!YourForm!YourControl

GetColumn = ctrl.Column(intCol)

End Function

Ken Sheridan
Stafford, England
 
Back
Top