This is the new SELECT statement - all 1 long line.
objOSRS.Open("SELECT DISTINCT [OperatingSystems.ID],
[OperatingSystems.OperatingSystem] FROM Matrix INNER JOIN
OperatingSystems ON Matrix.ModelID = OperatingSystems.ID WHERE
Matrix.ModelID = " + id + " AND Matrix.AppliesToOS = " + true + "
ORDER BY OperatingSystems.ID ASC", objFileCon, adOpenDynamic,
adLockOptimistic);
The bracketing is wrong: the tablenames should be in brackets, and the
fieldnames should be in brackets - but not the combination. Try
objOSRS.Open("SELECT DISTINCT [OperatingSystems].[ID],
[OperatingSystems].[OperatingSystem] FROM Matrix INNER JOIN
OperatingSystems ON Matrix.ModelID = OperatingSystems.ID WHERE
Matrix.ModelID = " + id + " AND Matrix.AppliesToOS = " + true + "
ORDER BY OperatingSystems.ID ASC", objFileCon, adOpenDynamic,
adLockOptimistic);
Or, since your names don't contain blanks or special characters, just leave
out the [] altogether.
This does assume that ModelID is numeric, AppliesToOS is a Boolean (Yes/No)
field, and that the constant True is equal to -1. You could just use the word
true as a criterion since Access will recognize it correctly:
" AND Matrix.AppliesToOS = True"
--
Hi,
Seems like ADO or something requires the brackets. If I use your
SELECT statement then I get the error: 'Item cannot be found in the
collection corresponding to the requested name or ordinal'. If I
remove the brackets then I get the same error message. Seems the
bracket format required is [Table.Field] in my case. You are correct
when you state: 'This assumes that ModelID is numeric, AppliesToOS is
a Boolean (Yes/No) field'.
This is my current SELECT statement - all 1 long line.
objOSRS.Open("SELECT DISTINCT [OperatingSystems.ID],
[OperatingSystems.OperatingSystem] FROM Matrix INNER JOIN
OperatingSystems ON Matrix.ModelID = OperatingSystems.ID WHERE
Matrix.ModelID = " + id + " AND Matrix.AppliesToOS = " + true + "
ORDER BY OperatingSystems.ID ASC", objFileCon, adOpenDynamic,
adLockOptimistic);
It returns the wrong results. In fact, I figured out what data is
returned but not why.
I have a <SELECT> dropdown box in my HTA listing all the models. The
value of each listing is the ModelID. I use parseInt to convert it to
numeric and pass it to the on_change function. I know the correct
ModelID is passed to the function, I can see it with an alert command.
I have 18 OS's listed in the OperatingSystems table, with IDs 1-18.
When I select one of the first 18 models listed then I get that value
returned by the SELECT statement. Once I select any model after 18
then I get 0 records returned.
So, if I select listing 1 then the SELECT statement returns 1. If I
select listing 10 then 10 is returned. If I select listing 18 then 18
is returned. These results are not correct. I should get a recordset
returned that show all OS's supported by that ModelID.
As I stated before, my original SELECT statement did return the
correct results. I am really lost now.
Thanks for your time and help,
Charles